I am trying to display multiple column of media store like artist,album,title etc .I am able to get one of the column in arraylist properly and it is working but when I add the
How to get both title and artist into your list:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custome_list, parent, false);
}
MediaFileInfo item = (MediaFileInfo) getItem(position);
TextView text1 = (TextView) convertView.findViewById(R.id.textView);
text1.setText(item.getTitle());
TextView text2 = (TextView) convertView.findViewById(R.id.textView2);
text2.setText(item.getArtist());
return convertView;
}
If you are getting data from the database and have a Cursor
then you should just create a CursorAdapter
subclass. You don't need to do the work of creating your own list from the data.
All you need to do is override bindView()
. bindView()
will hand you a View
to fill in for the list item and a Cursor
that is already positioned at the record that has the data for this item. It's a simple operation to get the column data from the cursor and set the child views in the list item view.