Caused by: java.lang.NoSuchMethodException: [class android.content.Context, interface android



在写自定义的view时,有时会报以下错误:


Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androidCaused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android

<view
         android:id="@id/viewpage_container"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_alignParentBottom="true"
         android:layout_below="@id/navigator"
         android:layout_centerHorizontal="true"
         class="com.suma.smartview.tv.ui.MainActivity$HomeViewPager"
         android:paddingTop="@dimen/px50" />

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


}


原因是:在xml中使用内部类的方式错了,MainActivity$HomeViewPager标示的是在MainActivity中有一个静态内部类HomeViewPager,所以HomeViewPaper应该声明为static ~




Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android,布布扣,bubuko.com

Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android

上一篇:从”茄子快传”看应用程序如何获取手机已安装程序的apk文件


下一篇:android延时处理任务范例