标签:android style class blog java http
在写自定义的view时,有时会报以下错误:
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
<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
标签:android style class blog java http
原文地址:http://blog.csdn.net/leehu1987/article/details/32324687