我制作了一个自定义的可扩展列表适配器。但是,我无法阻止我的孩子观看残疾。
在ExpandableListAdapter
中,我添加了以下内容,但它没有改变任何内容;
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
关于此的任何线索?
注意:在我的子视图中,我有一个RelativeLayout
,其中包含大量文本视图和ImageView
编辑:根据评论,这是整个适配器代码;
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
private Menu menu;
public ExpandableListAdapter(Context context, Menu menu) {
this.context = context;
this.menu = menu;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this.menu.groups.get(groupPosition).items.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
MenuItem item = (MenuItem) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.menu_list_item, null);
}
TextView name = (TextView) convertView.findViewById(R.id.item_name);
TextView price = (TextView) convertView.findViewById(R.id.item_price);
TextView description = (TextView) convertView.findViewById(R.id.item_description);
TextView contents = (TextView) convertView.findViewById(R.id.item_contents);
name.setText(item.name);
price.setText(item.price + " TL");
description.setText(item.description);
contents.setText(item.contents);
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return this.menu.groups.get(groupPosition).items.size();
}
@Override
public Object getGroup(int groupPosition) {
return this.menu.groups.get(groupPosition);
}
@Override
public int getGroupCount() {
return this.menu.groups.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
MenuGroup group = (MenuGroup) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.menu_list_group, null);
}
TextView groupText = (TextView) convertView.findViewById(R.id.group);
groupText.setText(group.name);
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}