I want to create a ListView with a header view that can be expanded and retractet just as in a ExpandableListView (but just the header view, all other views just be normal list items).
I'm using an ExpandableListView with a BaseExpandableListAdapter and treat all the other items in the list as groups that have no children. This is cumbersome and error-prone and has unwanted sideeffects.
I also tried using a normal ListView and a view for the header where I setVisivility(View.VISIBLE) to the expanded part of the view when the header view is clicked, but this doesn't seem to have any effect:
private View getHeaderView() {
final View v = layoutInflater.inflate(R.layout.headertest, null);
View v1 = v.findViewById(R.id.view1);
final View v2 = v.findViewById(R.id.view2);
v1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("head", "click");
v2.setVisibility(View.VISIBLE);
notifyDataSetChanged();
}
});
return v;
}
When v1 is clicked, the visibility of v2 is not changed, although the clickListener is called. I also tried .invalidate() on all kinds of views, to no avail.
Any ideas on how to solve this one or the other way?
0 comments:
Post a Comment