android ExpandableListView中的child是一个Gridview,但是GridView只能显示一行,怎么呢设置
迷茫2017-04-17 17:39:36
我跟你的相反,GridView嵌套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);
}
}
關鍵是onMeasure方法,
你可以將ListView改為GridView,其他不變