最近、曲を再生した音楽プレーヤーのプレイリストを作成しています。私は、曲のarraylistと共有の設定で再生されている曲のインデックスを格納しています。私が最近演奏した曲を手に入れようとしているのは、共有の設定からarraylistと曲のインデックスを取得し、別のarraylistに保存することです。しかし、問題はrecyclerViewが一度に1つの曲だけを表示することです。最新の曲を取り出す方法は?
例:私がA曲を演奏した場合、recyclerViewは最初の位置に曲Aを表示し、次にB曲を再生すると、recyclerViewは曲Bを最初の位置に、曲Aを2番目の位置に表示する必要があります。しかし、それは最初の位置を示すだけです。
RecentlyPLayedsongs.java
:
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = LayoutInflater.from(this);
View view6 = inflater.inflate(R.layout.activity_recently_played, null);
FrameLayout container6 = (FrameLayout) findViewById(R.id.container);
container6.addView(view6);
recyclerView_recently_played = findViewById(R.id.recyclerView_recently_played);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView_recently_played.setLayoutManager(linearLayoutManager);
StorageUtil storageUtil2 = new StorageUtil(getApplicationContext());
SongList=storageUtil2.loadAudio();
pos = storageUtil2.loadAudioIndex();
songInfoModel = SongList.get(pos);
RecentlyPlayedList.add(songInfoModel);
adapter1 = new Playlist_Recently_Added_Adapter(RecentlyPlayedList, getApplicationContext());
recyclerView_recently_played.setAdapter(adapter1);
}
これは、ソングbを再生するときに配列の2番目の位置に追加することを意味しますか? –
曲Bが再生されているときに曲Aが2番目の位置に追加され、曲Bが通常の音楽プレーヤーのように最初の位置に追加されます。 – Rektirino