Android Multiple Objects In Simpleadapter
I have a need (unless you can think of a better way) of passing multiple objects to a custom list adapter. I know that I'm barking up the wrong tree here, and would appreciate som
Solution 1:
1) The first line says that you needs to pass object into the adapter. Your code says that you are doing so. So your implied question is ambiguous.
2) It's not working because you passed null (instead of a list) in the constructor.
super(context, null, resource, from, to);
This is what is expected: super(Context, List<Map<String, ?>>, int, String[], int[])
3) The null that you passed in your adapter's constructor causes the internal List for simple adapter to be null. It being null means that SimpleAdapter.getCount() has no object (list) to get the quantity of.
Solution 2:
AedonEtLIRA, thanks for your help. In the end I opted to change the SimpleAdapter
to ArrayAdapter
.
publicclassMyPlayListAdapterextendsArrayAdapter<Song> {
private ArrayList<Song> songsList;
private ArrayList<Song> playlistcheck = newArrayList<Song>();
private ArrayList <Song> retained_songsList = newArrayList<Song>();
private String folderMode;
privateStringTAG="AndroidMediaCenter";
publicMyPlayListAdapter(Context context, int textViewResourceId, ArrayList<Song> songsList, ArrayList<Song> retained_songsList, String folderMode) {
super(context, textViewResourceId, songsList);
this.songsList = songsList;
this.retained_songsList = retained_songsList;
this.folderMode = folderMode;
}
called from my main activity by:
playlistadapter = newMyPlayListAdapter(MyApplication.getAppContext(),
R.layout.file_view,
songsList,
retained_songsList,
folderMode);
Post a Comment for "Android Multiple Objects In Simpleadapter"