首页 > 移动平台 > 详细

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

时间:2014-06-22 15:44:51      阅读:1182      评论:0      收藏:0      [点我收藏+]


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


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

bubuko.com,布布扣bubuko.com,布布扣

<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

原文:http://blog.csdn.net/leehu1987/article/details/32324687

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!