建立类ListViewInScrollView
public class ListViewInScrollView extends ListView { public ListViewInScrollView(Context context) { super(context); // TODO Auto-generated constructor stub } public ListViewInScrollView(Context context, AttributeSet attrs) { super(context,attrs); } public ListViewInScrollView(Context context, AttributeSet attrs, int defStyle) { super(context,attrs,defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }
布局中listview换成
<com.ceshi.views.ListViewInScrollView android:id="@+id/formcustomspinner_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:cacheColorHint="@null" android:divider="@android:drawable/divider_horizontal_bright" android:scrollbars="none" />