Reputation: 4013
with Android Studio I have this ListView in the MainActivity
ArrayAdapter<RSSItem> adapter;
adapter = new ArrayAdapter<RSSItem>(this,
android.R.layout.simple_list_item_1,myRssFeed.getList());
setListAdapter(adapter);
and this shows me the title of the feed I return from RSSItem. Is there a way to have the description, images, ecc. for SUBITEM and the title I return for ITEM?
Upvotes: 0
Views: 1189
Reputation: 1810
You can use Expendable list which will allow you to show group and kind of sub-group. To do so you need to create a BaseExpandableListAdapter. You need to override two methods of this class.
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.group_row, null);
}
//TextView tv=new TextView(context);
TextView tv = (TextView) convertView.findViewById(R.id.tvGroupName);
//tv.setText(parentList[groupPosition]);
tv.setText(category_list.get(groupPosition).toString());
//tv.setPadding(70,0,0,10);
//return tv;
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.child_row, null);
}
//TextView tv=new TextView(context);
TextView tv = (TextView) convertView.findViewById(R.id.tvPlayerName);
//tv.setText(childList[groupPosition][childPosition]);
tv.setText((String)((ArrayList)sub_category_list.get(groupPosition)).get(childPosition));
//tv.setPadding(70,0,0,10);
//return tv;
return convertView;
}
Upvotes: 7