我在DrawerList中有这个结构:
我需要隐藏"更多......"当它打开时。
在此细分上执行此操作:
public class CategoryItemsAdapter extends BaseExpandableListAdapter {
...
public View getChildView(int groupPosition, int childPosition, boolean isExpanded, View view,
ViewGroup parent) {
Link child = (Link) getChild(groupPosition, childPosition);
LinksGroup group = (LinksGroup) getGroup(groupPosition);
if (view == null) {
LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
view = infalInflater.inflate(R.layout.category_item_counter, null);
}
TextView tv = (TextView) view.findViewById(R.id.title);
tv.setText(child.getName().toString());
if(isExpanded) {
}
else {
}
return view;
}
public View getGroupView(int groupPosition, boolean isLastChild, View view,
ViewGroup parent) {
LinksGroup group = (LinksGroup) getGroup(groupPosition);
String groupTitle = getGroup(groupPosition).toString();
View viewGroup = new FrameLayout(context);
if (view == null) {
LayoutInflater inf = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
view = inf.inflate(R.layout.category_item_counter, null);
}
TextView tv = (TextView) view.findViewById(R.id.title);
final float scale = context.getResources().getDisplayMetrics().density;
int space = (int) (20 * scale + 0.5f);
int item = (int) (40 * scale + 0.5f);
if(group.getName() == null) {
tv.setBackgroundColor(Color.DKGRAY);
tv.setHeight(space);
tv.setText("");
}
else {
tv.setBackgroundColor(Color.WHITE);
tv.setHeight(item);
tv.setText(group.getName());
}
return view;
}
...
}
或者我可以在OnGroupClickListener上执行此操作吗?
我想了很久。需要帮助。
答案 0 :(得分:0)
好的,我刚补充说:
if(isExpanded) {
tv.setHeight(0);
return view;
}
到
public View getGroupView(int groupPosition, boolean isExpanded, View view,
ViewGroup parent)