gpt4 book ai didi

java - 为什么 Recycler View 会滚动回最后三项?

转载 作者:太空宇宙 更新时间:2023-11-04 12:23:56 24 4
gpt4 key购买 nike

我想通过“RecyclerView”显示设备中的歌曲列表。列表中的每个项目都包含一些子项目,例如歌曲名称专辑封面等。当回收器 View 设置为仅显示歌曲名称和“无专辑封面”等详细信息时,它工作正常,因为滚动平滑并且轻松滚动到最后,但是当我显示列表中每首歌曲的专辑封面时,就会出现问题。问题是,当我用一次长滚动将歌曲滚动到最后一项时(因为列表非常小,所以我们可以用一次滚动滚动到最后一项),回收器 View 向我显示滚动动画,直到列表中的最后一项,当滚动动画停止时,回收器 View 最终显示最后三个列表项,我再滚动一次以获取屏幕上的最后一个列表项。我正在使用毕加索库来显示专辑封面,并且我通过以下代码行获取专辑封面“Uri”:

Uri ART_CONTENT_URI = Uri.parse("content://media/external/audio/albumart");
Uri albumArtUri = ContentUris.withAppendedId(ART_CONTENT_URI,thisAlbumId);

我将适配器设置为回收器 View ,如下所示:

new Thread(new Runnable()
{
@Override
public void run()
{
MusicService.songList = new ArrayList<>();
getSongList();
runOnUiThread(new Runnable()
{
@Override
public void run()
{
recyclerView=(RecyclerView) findViewById(R.id.song_list_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerViewAdapter = new RecyclerViewAdapter(MainActivity.this);
recyclerView.setAdapter(recyclerViewAdapter);
recyclerView.setHasFixedSize(true);
}
});
}
}).start();

我希望你能很好地理解它。寻找错误,例如我做错的事情或忘记的事情。

这是我的错误日志:

07-24 23:55:43.698 6069-6069/com.sayings.developer.music E/ExtMediaPlayer-JNI: QCMediaPlayer could not be located....
07-24 23:55:43.698 6069-6069/com.sayings.developer.music E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
07-24 23:55:43.698 6069-6069/com.sayings.developer.music E/ExtMediaPlayer-JNI: QCMediaPlayer could not be located....
07-24 23:55:43.699 6069-6069/com.sayings.developer.music E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
07-25 00:02:04.123 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:05.273 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:05.415 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:05.488 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:06.242 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:07.087 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:23.624 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout
07-25 00:02:25.452 6069-6069/com.sayings.developer.music E/RecyclerView: No adapter attached; skipping layout

最佳答案

问题是附加到回收器 View 的 ArrayAdapter 的值发生了变化,因此我更改了逻辑并删除了错误。

关于java - 为什么 Recycler View 会滚动回最后三项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38554777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com