Anroid ListView嵌套ListView

List中显示的界面中还有ListView的情况,底层的Listview只会显示一行,即高度没法确定。
 

将底层的Listview重写即可


public class MyListView extends ListView {
 public MyListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public MyListView(Context context) {
        super(context);
    }
    public MyListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(
                Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}

你可能感兴趣的:(Anroid ListView嵌套ListView)