我有一个ExandableListView和以下BaseExpandableListAdapter:
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Activity context;
private Map<String, List<String>> navItemsCollection;
private List<String> groupList;
public ExpandableListAdapter(Activity context, List<String> groupItems,
Map<String, List<String>> navItemsCollection) {
this.context = context;
this.groupList = groupItems;
this.navItemsCollection = navItemsCollection;
}
public String getChild(int groupPosition, int childPosition) {
return navItemsCollection.get(groupList.get(groupPosition)).get(childPosition);
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String laptop = (String) getChild(groupPosition, childPosition);
LayoutInflater inflater = context.getLayoutInflater();
if (convertView == null) {
convertView = inflater.inflate(R.layout.nav_child_item, null);
}
TextView item = (TextView) convertView.findViewById(R.id.laptop);
item.setText(laptop);
return convertView;
}
public int getChildrenCount(int groupPosition) {
return navItemsCollection.get(groupList.get(groupPosition)).size();
}
public String getGroup(int groupPosition) {
return groupList.get(groupPosition);
}
public int getGroupCount() {
return groupList.size();
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.nav_group_item, null);
}
TextView item = (TextView) convertView.findViewById(R.id.laptop);
item.setTypeface(null, Typeface.BOLD);
item.setText(getGroup(groupPosition));
return convertView;
}
public boolean hasStableIds() {
return true;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
我希望可扩展列表视图的某些行通常像ListView一样,并且不包含箭头。单击它的方法应该调用一个函数。 有没有办法实现这个目标?