//创建一个动态适配的class
package com.example.items_sj.views;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
/**
* Created by Administrator on 2017/12/21.
*/
public class MyListView extends ListView{
public MyListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int i = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, i);
}
}
//这是布局
<?xml version="1.0" encoding="utf-8"?>
<com.handmark.pulltorefresh.library.PullToRefreshScrollView xmlns:android="http://schemas.android.com/apk/res/android
"
xmlns:tools="http://schemas.android.com/tools
"
android:id="@+id/psv"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.items_sj.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="wrap_content"
android:layout_height="200dp" />
<com.example.items_sj.views.MyListView
android:id="@+id/mlv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>