0
我有這樣的自定義視圖類作爲內部類:自定義滾動型NoSuchMethodException
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): Caused by: java.lang.NoSuchMethodException: [class android.content.Context, interface android.util.AttributeSet]
爲什麼?