Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 嵌套可展开列表视图编辑文本折叠列表视图_Android_Xml_Expandablelistview - Fatal编程技术网

Android 嵌套可展开列表视图编辑文本折叠列表视图

Android 嵌套可展开列表视图编辑文本折叠列表视图,android,xml,expandablelistview,Android,Xml,Expandablelistview,大家好,我已经构建了这个嵌套的可扩展列表,所有的东西都正常工作,除了当编辑文本被聚焦时,整个列表被折叠。提供程序和xml视图的代码。我错过了什么 外部列表 public class DashboardDrawerExpandableListAdapter extends BaseExpandableListAdapter { Context mAdapterContext; private List<String> _listDataHeader; // heade

大家好,我已经构建了这个嵌套的可扩展列表,所有的东西都正常工作,除了当编辑文本被聚焦时,整个列表被折叠。提供程序和xml视图的代码。我错过了什么

外部列表

public class DashboardDrawerExpandableListAdapter extends BaseExpandableListAdapter {

    Context mAdapterContext;
    private List<String> _listDataHeader; // header titles
    private HashMap<String, List<String>> _listDataChild;
    private ExpandableListView mParent;

    List<String> listDataHeader;
    HashMap<String, List<String>> listDataChild;


    public DashboardDrawerExpandableListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData, ExpandableListView parent) {
        this.mAdapterContext = context;
        this._listDataHeader = listDataHeader;
        this._listDataChild = listChildData;
        this.mParent = parent;
    }

    @Override
    public Object getChild(int groupPosition, int childPosititon) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        final String childText = (String) getChild(groupPosition, childPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) mAdapterContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.dashboard_drawer_inner_expandable_list_header, null);
        }

        prepareInnerListData();

        ExpandableListView innerExpandableList =(ExpandableListView) convertView.findViewById(R.id.inner_expandable_list);
        DashboardDrawerExpandableInnerListAdapter drawerexpandableadapter = new DashboardDrawerExpandableInnerListAdapter(mAdapterContext, listDataHeader, listDataChild,innerExpandableList);
        innerExpandableList.setAdapter(drawerexpandableadapter);

        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return this._listDataHeader.get(groupPosition);
    }

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

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        String headerTitle = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) mAdapterContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.dashboard_drawer_expandable_list_header_item, null); // main greyed header
            TextView groupHeader = (TextView) convertView.findViewById(R.id.groupHeaderText);
            groupHeader.setTypeface(null, Typeface.BOLD);
            groupHeader.setText(headerTitle);
        }
        return convertView;
    }

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

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    private void prepareInnerListData() {
        listDataHeader = new ArrayList<String>();
        listDataChild = new HashMap<String, List<String>>();

        // Adding child data
        listDataHeader.add("Date Range");
        listDataHeader.add("Location(s)");

        // Adding child data
        List<String> filteritems = new ArrayList<String>();
        filteritems.add(" ");

        listDataChild.put(listDataHeader.get(0), filteritems);
        listDataChild.put(listDataHeader.get(1), filteritems);
    }
}
公共类DashboardDrawerExpandableListAdapter扩展了BaseExpandableListAdapter{
语境;语境;
私有列表_listDataHeader;//头标题
私有HashMap_listDataChild;
私有可扩展列表视图;
列表列表数据头;
HashMapListDataChild;
公用仪表板抽屉ExpandableListAdapter(上下文上下文、列表listDataHeader、HashMap listChildData、ExpandableListView父级){
this.mAdapterContext=上下文;
这。_listDataHeader=listDataHeader;
这。_listDataChild=listChildData;
this.mParent=parent;
}
@凌驾
公共对象getChild(int-groupPosition、int-ChildPosition){
返回此。_listDataChild.get(此。_listDataHeader.get(groupPosition)).get(childpositionon);
}
@凌驾
公共长getChildId(int-groupPosition,int-childPosition){
返回子位置;
}
@凌驾
公共视图getChildView(int-groupPosition,final int-childPosition,boolean isLastChild,View-convertView,ViewGroup-parent){
最终字符串childText=(字符串)getChild(groupPosition,childPosition);
if(convertView==null){
LayoutInflater infalInflater=(LayoutInflater)mAdapterContext.getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
convertView=infalInflater.flate(右布局、仪表板、抽屉、内部、可扩展列表、标题,空);
}
prepareInnerListData();
ExpandableListView innerExpandableList=(ExpandableListView)convertView.findViewById(R.id.inner\u expandable\u list);
DashboardDrawerExpandableInnerListAdapter drawerexpandableadapter=新的DashboardDrawerExpandableInnerListAdapter(mAdapterContext、listDataHeader、listDataChild、innerExpandableList);
setAdapter(抽屉扩展适配器);
返回视图;
}
@凌驾
公共整数getChildrenCount(整数组位置){
返回此。_listDataChild.get(此。_listDataHeader.get(groupPosition)).size();
}
@凌驾
公共对象getGroup(int-groupPosition){
返回此。\u listDataHeader.get(groupPosition);
}
@凌驾
public int getGroupCount(){
返回此值。_listDataHeader.size();
}
@凌驾
公共长getGroupId(int-groupPosition){
返回组位置;
}
@凌驾
公共视图getGroupView(int groupPosition、布尔isExpanded、视图convertView、视图组父级){
字符串头文件=(字符串)getGroup(groupPosition);
if(convertView==null){
LayoutInflater infalInflater=(LayoutInflater)mAdapterContext.getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
convertView=infalInflater.flate(R.layout.dashboard\u drawer\u expandable\u list\u header\u item,null);//主灰色表头
TextView groupHeader=(TextView)convertView.findViewById(R.id.groupHeaderText);
groupHeader.setTypeface(null,Typeface.BOLD);
groupHeader.setText(headerTitle);
}
返回视图;
}
@凌驾
公共布尔表ID(){
返回false;
}
@凌驾
公共布尔值isChildSelectable(int-groupPosition,int-childPosition){
返回true;
}
私有void prepareInnerListData(){
listDataHeader=新的ArrayList();
listDataChild=newHashMap();
//添加子数据
添加(“日期范围”);
添加(“位置”);
//添加子数据
List filteritems=新建ArrayList();
filteritems。添加(“”);
listDataChild.put(listDataHeader.get(0),filteritems);
listDataChild.put(listDataHeader.get(1),filteritems);
}
}
内部列表

public class DashboardDrawerExpandableInnerListAdapter extends BaseExpandableListAdapter {
    Context mAdapterContext;
    private List<String> _listDataHeader; // header titles
    private HashMap<String, List<String>> _listDataChild;
    private ExpandableListView mParent;

    public DashboardDrawerExpandableInnerListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData, ExpandableListView parent) {
        this.mAdapterContext = context;
        this._listDataHeader = listDataHeader;
        this._listDataChild = listChildData;
        this.mParent = parent;
    }

    @Override
    public Object getChild(int groupPosition, int childPosititon) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        final String childText = (String) getChild(groupPosition, childPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) mAdapterContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            switch (groupPosition){
                case 0:
                    convertView = infalInflater.inflate(R.layout.expandable_list_item_date_range, null);
                    break;
                case 1:
                    convertView = infalInflater.inflate(R.layout.expandable_list_item_locations, null);
                    break;
                default:
                    break;
            }
        }
        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return this._listDataHeader.get(groupPosition);
    }

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

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        String headerTitle = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) mAdapterContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            switch (groupPosition){
                case 0:
                    convertView = infalInflater.inflate(R.layout.expandable_list_header_date_range, null);
                    break;
                case 1:
                    convertView = infalInflater.inflate(R.layout.expandable_list_header_location, null);
                    break;
                default:
                    break;
            }
        }

        TextView groupHeader = (TextView) convertView.findViewById(R.id.inner_group_header_text);
        groupHeader.setTypeface(null, Typeface.BOLD);
        groupHeader.setText(headerTitle);

        return convertView;
    }

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

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
公共类DashboardDrawerExpandableInnerListAdapter扩展了BaseExpandableListAdapter{
语境;语境;
私有列表_listDataHeader;//头标题
私有HashMap_listDataChild;
私有可扩展列表视图;
公用仪表板抽屉ExpandableInnerListAdapter(上下文上下文、列表listDataHeader、HashMap listChildData、ExpandableListView父级){
this.mAdapterContext=上下文;
这。_listDataHeader=listDataHeader;
这。_listDataChild=listChildData;
this.mParent=parent;
}
@凌驾
公共对象getChild(int-groupPosition、int-ChildPosition){
返回此。_listDataChild.get(此。_listDataHeader.get(groupPosition)).get(childpositionon);
}
@凌驾
公共长getChildId(int-groupPosition,int-childPosition){
返回子位置;
}
@凌驾
公共视图getChildView(int-groupPosition,final int-childPosition,boolean isLastChild,View-convertView,ViewGroup-parent){
最终字符串childText=(字符串)getChild(groupPosition,childPosition);
if(convertView==null){
LayoutInflater infalInflater=(LayoutInflater)mAdapterContext.getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
开关(组位置){
案例0:
convertView=infalInflater.充气(R.layout.expandable\u list\u item\u date\u range,空);
打破
案例1:
convertView=充气机充气(R.layout.expandable\u list\u item\u locations,null);
打破
违约:
打破
}
}
返回视图;
}
@凌驾
公共整数getChildrenCount(整数组位置){
返回此。_listDataChild.get(此。_listDataHeader.get(groupPosition)).size();
}
@凌驾
公共对象getGroup(int-groupPo
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:background="#616161"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:padding="10dp">

        <TextView
            android:layout_width="0dp"
            android:layout_weight=".5"
            android:layout_height="wrap_content"
            android:id="@+id/groupHeaderText"
            android:textSize="18sp"
            android:layout_gravity="center" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Reset"
            android:id="@+id/button2"
            android:focusable="false"
            android:layout_weight=".5"
            android:layout_gravity="center" />
    </LinearLayout>

</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ExpandableListView
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:isScrollContainer="false"
        android:id="@+id/inner_expandable_list" />

</LinearLayout>