android ExpandableListView中的child是一个Gridview
迷茫
迷茫 2017-04-17 17:37:36
0
1
509

android ExpandableListView中的child是一个Gridview,但是GridView只能显示一行,怎么呢设置

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
迷茫

I am opposite to you, GridView nested ListView


import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;

public class ChildListView extends ListView {

    public ChildListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    public ChildListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public ChildListView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}

The key is the onMeasure method,
You can change ListView to GridView, and the others remain unchanged

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template