自定义控件继承父类,我只重写了一个构造方法,导致项目调试运行一直失败。解决方案:至少是默认的前三个。(这里继承自ListView类)
public class NonScrollableListView extends ListView{ public NonScrollableListView(Context context) { super(context); } public NonScrollableListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollableListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }