ListView适应ScrollView的效果,不冲突

1.

/**
* onMeasure重写该方法,达到使ListView适应ScrollView的效果,不冲突
* */
public class ListViewForScrollView extends ListView {
    public ListViewForScrollView(Context context) {
        super(context);
    }

    public ListViewForScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ListViewForScrollView(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * 重写该方法,达到使ListView适应ScrollView的效果
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}

2.

//绑定
listview = (ListViewForScrollView) v.findViewById(R.id.listview);
//直投直贷专区listview列表adapter
                indexAdapter = new IndexAdapter(getActivity(), data);
                listview.setAdapter(indexAdapter);

你可能感兴趣的:(ListView适应ScrollView的效果,不冲突)