自定义ScrollView NoSuchMethodException

时间:2013-04-04 20:31:58

标签: android scrollview

我将此自定义视图类作为内部类:

public class GraphFragment extends SherlockFragment {
[...]
    public class FlingableScrollView extends ScrollView {
        public FlingableScrollView(Context context, AttributeSet attrs,
                int defStyle) {
             super(context, attrs, defStyle);
        }

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

         public FlingableScrollView(Context context) {
             super(context);
         }

         @Override
         public boolean dispatchTouchEvent(MotionEvent ev) {
             super.dispatchTouchEvent(ev);
             return gestureListener.onTouch(this, ev);
         }
     }
}

在我的XML布局中:

        <view
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.example.GraphFragment$FlingableScrollView" >

由于此错误,它无效:

  

04-04 20:04:41.001:E / AndroidRuntime(2011):引起:   java.lang.NoSuchMethodException:[class   android.content.Context,接口android.util.AttributeSet]

为什么?

1 个答案:

答案 0 :(得分:1)

在这个问题中提出了类似的问题。看看它是否有帮助。

Implementing extended/custom View throws NoSuchMethod for constructor

相关问题