android ExpandableListView中的child是一个Gridview,但是GridView只能显示一行,怎么呢设置
迷茫2017-04-17 17:39:36
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