Expandablelistview 使expandviewlist可选择

Expandablelistview 使expandviewlist可选择,expandablelistview,expandablelistadapter,Expandablelistview,Expandablelistadapter,我对编程非常陌生,只是尽可能多地学习。我正在尝试为我们公司创建一个非常简单的应用程序来打印标签。我已经创建了一个expandablelistadapter,并成功地在视图中获取了所有的材质。但是,我无法选择任何子项并将其显示在应用程序中。下面是我用于适配器的代码。我在这个网站上尝试了几个选项,但没有一个对我有效。我肯定这是我要忽略的简单的事情 公共类ExpandableListAdapter扩展了BaseExpandableListAdapter{ private Context context

我对编程非常陌生,只是尽可能多地学习。我正在尝试为我们公司创建一个非常简单的应用程序来打印标签。我已经创建了一个expandablelistadapter,并成功地在视图中获取了所有的材质。但是,我无法选择任何子项并将其显示在应用程序中。下面是我用于适配器的代码。我在这个网站上尝试了几个选项,但没有一个对我有效。我肯定这是我要忽略的简单的事情

公共类ExpandableListAdapter扩展了BaseExpandableListAdapter{

private Context context;
private List<String> expandableListTitle;
private HashMap<String, List<String>> expandableListDetail;

public ExpandableListAdapter(Context context, List<String> expandableListTitle,
                             HashMap<String, List<String>> expandableListDetail) {
    this.context = context;
    this.expandableListTitle = expandableListTitle;
    this.expandableListDetail = expandableListDetail;
}

@Override
public Object getChild(int listPosition, int expandedListPosition) {
    return this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
            .get(expandedListPosition);
}

@Override
public long getChildId(int listPosition, int expandedListPosition) {
    return expandedListPosition;
}

@Override
public View getChildView(int listPosition, final int expandedListPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {
    final String expandedListText = (String) getChild(listPosition, expandedListPosition);
    if (convertView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) this.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(R.layout.list_item, null);
    }
    TextView expandedListTextView = (TextView) convertView
            .findViewById(R.id.expandedListItem);
    expandedListTextView.setText(expandedListText);
    return convertView;

}

@Override
public int getChildrenCount(int listPosition) {
    return this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
            .size();
}

@Override
public Object getGroup(int listPosition) {
    return this.expandableListTitle.get(listPosition);
}

@Override
public int getGroupCount() {
    return this.expandableListTitle.size();
}

@Override
public long getGroupId(int listPosition) {
    return listPosition;
}

@Override
public View getGroupView(int listPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    String listTitle = (String) getGroup(listPosition);
    if (convertView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) this.context.
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(R.layout.list_group, null);
    }
    TextView listTitleTextView = (TextView) convertView
            .findViewById(R.id.listTitle);
    listTitleTextView.setTypeface(null, Typeface.BOLD);
    listTitleTextView.setText(listTitle);
    return convertView;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public boolean isChildSelectable(int listPosition, int expandedListPosition) {
    return false;
私有上下文;
私有列表expandableListTitle;
私有HashMap expandableListDetail;
公共ExpandableListAdapter(上下文,列表expandableListTitle,
HashMap expandableListDetail){
this.context=上下文;
this.expandableListTitle=expandableListTitle;
this.expandableListDetail=expandableListDetail;
}
@凌驾
公共对象getChild(int listPosition,int expandedListPosition){
返回this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
.get(expandedListPosition);
}
@凌驾
公共长getChildId(int-listPosition、int-expandedListPosition){
返回expandedListPosition;
}
@凌驾
公共视图getChildView(int listPosition,最终int expandedListPosition,
布尔值isLastChild、视图转换视图、视图组父级){
最终字符串expandedListText=(字符串)getChild(listPosition,expandedListPosition);
if(convertView==null){
LayoutInflater LayoutInflater=(LayoutInflater)this.context
.getSystemService(上下文布局\充气机\服务);
convertView=LayoutFlater.充气(R.layout.list_项,空);
}
TextView expandedListTextView=(TextView)convertView
.findViewById(R.id.expandedListItem);
expandedListTextView.setText(expandedListText);
返回视图;
}
@凌驾
公共int getChildrenCount(int listPosition){
返回this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
.size();
}
@凌驾
公共对象getGroup(int listPosition){
返回此.expandableListTitle.get(listPosition);
}
@凌驾
public int getGroupCount(){
返回此.expandableListTitle.size();
}
@凌驾
公共长getGroupId(int-listPosition){
返回列表位置;
}
@凌驾
公共视图getGroupView(int listPosition,布尔值isExpanded,
视图(视图、视图组父级){
字符串listTitle=(字符串)getGroup(listPosition);
if(convertView==null){
LayoutInflater LayoutInflater=(LayoutInflater)this.context。
getSystemService(上下文布局\充气机\服务);
convertView=LayoutFlater.充气(R.layout.list\u组,空);
}
TextView listTitleTextView=(TextView)convertView
.findViewById(R.id.listTitle);
listTitleTextView.setTypeface(null,Typeface.BOLD);
setText(listTitle);
返回视图;
}
@凌驾
公共布尔表ID(){
返回false;
}
@凌驾
公共布尔值isChildSelectable(int listPosition,int expandedListPosition){
返回false;