When writing a custom view, the following error is sometimes reported:
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);
}
}
The reason is that the use of internal classes in XML is wrong, andMainactivity$homeviewpager indicates that there is a static inner class Homeviewpager in the Mainactivity, So homeviewpaper should be declared as static ~