I am using list fragment with a list header and need to add a set of list inside the first list item.
I am using custom list adapter to load the list items. Now for List Item 1 – I need to add a subview on top of list item from within the list adapter. How should I go about this? I am not sure if expandable list item is what I wanna use here.
My custom adapter's getView looks something like this:
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
int type = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch (type) {
case TYPE_LIST_ITEM_1:
convertView = mInflater.inflate(R.id.list_item_one, null);
/* add code */
/* add another list adapter? */
break;
case TYPE_LIST_ITEM_OTHERS:
convertView = mInflater.inflate(R.layout.list_item_other, null);
/* add code for below list */
break;
}
convertView.setTag(holder);
}
else {
holder = (ViewHolder)convertView.getTag();
}
return convertView;
}
What would be a optimal way of going about it, without losing the header view which uses
myListView.addHeaderView(myHeaderView);
Best Answer
A
ScrollView
in aScrollView
isn't possible on Android without major bugs, Google says to not do it. You could have aLinearLayout
inside of your list item (with itsorientation
set tovertical
) and manually useaddView()
to add views to the LinearLayout that will be displayed with the layout's set orientation.