I am working in android. I am creating a music application. in this application i want to show title of song and name of artist into list.
this is my code :-
String[] title_of_song={"title1","title2","title3","title4","title5"};
String[] artist_of_song={"artist1","artist2","artist3","artist4","artist5"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row_button, R.id.TextView_songName, title_of_song);
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, R.layout.row_button, R.id.TextView_byArtist, artist_of_song);
list.setAdapter(adapter);
list.setAdapter(adapter1); //**this is creating error**
this is creating problem that list is unable to setAdapter two times. so please tell me solution for it so i can set setAdapter for both title of song and artist name.
this is creating problem that list is unable to setAdapter two times. so please tell me solution for it so i can set setAdapter for both title of song and artist name.
Thank you in advance.
I do not know what are you trying to achieve. both your adapters have identical codes. why not create a single adapter that has values of both adapters.
Just saw your edited question
create a custom adapter and inflate a layout which has two textviews – one for artist and one for the song.