如何在android中消耗耗尽列表视图后滚动组和子

时间:2017-01-13 05:18:02

标签: android

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"

    >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="12dp">

            <ExpandableListView
                android:id="@+id/expandableListView"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/text2"
                android:layout_marginLeft="11dp"
                android:layout_marginStart="11dp"
                android:divider="@android:color/darker_gray"

                android:dividerHeight="0.5dp"
                android:indicatorLeft="?android:attr/expandableListPreferredItemIndicatorLeft" />


        </LinearLayout>
    </ScrollView>

</android.support.v7.widget.CardView>

这是我的代码:

 expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
        expandableListDetail = ExpandableListDataPump.getData();
        expandableListTitle = new ArrayList<String>(expandableListDetail.keySet());
        expandableListAdapter = new CustomExpandableListAdapter(this, expandableListTitle, expandableListDetail);
        expandableListView.setAdapter(expandableListAdapter);

        expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {

            @Override
            public void onGroupExpand(int groupPosition) {

                groupName = expandableListTitle.get(groupPosition);
                listtG1 = ExpandableListDataPump.getData().get(groupName);
                Log.d("ListSize", String.valueOf(listtG1.size()));



            }
        });


        expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {

                groupName = expandableListTitle.get(groupPosition);
                listtG1 = ExpandableListDataPump.getData().get(groupName);

                Toast.makeText(
                        getApplicationContext(),
                        groupName, Toast.LENGTH_SHORT
                ).show();

                Log.d("ListSize", String.valueOf(listtG1.size()));


                if (listtG1.size() == 1 && listtG1.get(0).equals(groupName)) {


                    return true;
                } else


                    return false;

            }
        });


        expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                                        int groupPosition, int childPosition, long id) {


                childName = listtG1.get(childPosition);
                Toast.makeText(
                        getApplicationContext(),
                        childName, Toast.LENGTH_SHORT
                ).show();


                return false;
            }
        });

这是我的代码,用于消耗性列表视图,当组没有消耗时打印数据,或者如果组消费和子项只包含一个数据,那么它看起来是正确的。

enter image description here

但是当我花费和儿童接触超过2或3个数据时,其他组就会像这样隐藏enter image description here

我想要实际的团体消费,然后其他也应该显示,它应该滚动与孩子和组请告诉我或建议我如何解决它。

0 个答案:

没有答案