第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)我意圖 arrayList 的數(shù)據(jù)時,如何在第二個活動以及 setText 和 Image

當(dāng)我意圖 arrayList 的數(shù)據(jù)時,如何在第二個活動以及 setText 和 Image

POPMUISE 2023-10-19 21:16:58
我使用 ArrayList 制作了一個歌曲列表,并且獲得了所有信息,并且可以將其傳遞給第二個活動并在新頁面上打開它。我想要的是當(dāng)我單擊歌曲列表時,它會在新頁面中打開,新頁面會顯示歌曲的詳細(xì)信息和圖像。@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    listView_Main=findViewById(R.id.listView_Main);    final Song song1 = new Song("Love Story","Taylor Swift","September 12,2008", "$1.29");    Song song2 = new Song("Lover","Taylor Swift","August 23,2019", "$1.29" );    Song song3 = new Song("I Forgot That You Existed", "Taylor Swift", "August 23,2019", "$1.29");    Song song4 = new Song("The Archer", "Taylor Swift", "August 23,2019", "$1.29");    Song song5 = new Song("I Think He Knows","Taylor Swift", "August 23,2019", "$1.29");    final List<Song> songs = new ArrayList<>();    songs.add(song1);    songs.add(song2);    songs.add(song3);    songs.add(song4);    songs.add(song5);      MainAdapter adapter = new MainAdapter(this, songs);      listView_Main.setAdapter(adapter);     listView_Main.setOnItemClickListener(new AdapterView.OnItemClickListener() {         @Override         public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {             Intent intent=new Intent(view.getContext(),SongDetailActivity.class);             intent.putExtra("currentSong",(Serializable) songs.get(i));             startActivity(intent);         }     });}但我的問題是在第二個活動中,我不知道如何使用 setText 獲取歌曲和圖像的詳細(xì)信息。因此,我在 String.xml 文件中制作了歌曲詳細(xì)信息。我怎樣才能在第二個活動中獲得這些細(xì)節(jié)和圖像?另外,我不知道如何獲取第二個活動中歌曲列表的位置,我的意思是我單擊的哪首歌曲的位置,并且它顯示了我單擊的那首歌曲的詳細(xì)信息。//這里是歌曲詳細(xì)信息的第二個活動。////// @Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_song_detail);    textViewSongDetail=findViewById(R.id.textView_SongDetail);    imageViewSongDetail=findViewById(R.id.image_SongDetail);    Song currentSong=(Song)getIntent().getSerializableExtra("currentSong");}
查看完整描述

1 回答

?
回首憶惘然

TA貢獻1847條經(jīng)驗 獲得超11個贊

首先,確保您已在模型類 Song 中實現(xiàn)了 Serialized。比你的代碼可以正常工作。并接收您可以發(fā)送的位置 -


intent.putExtra("position", i);   // to send 


getIntent().getIntExtra("position", -1);  //to receive (-1 is default value)


查看完整回答
反對 回復(fù) 2023-10-19
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號