0
我想生一个设置我的内容查看这样的:无法设置内容查看,崩溃的应用程序
这是我的onCreate方法:
RelativeLayout mainView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainView = (RelativeLayout)findViewById(R.id.mainView);
setContentView(mainView);
}
的“MAINVIEW”是下面的XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
现在,启动应用程序时,我得到一些:
02-20 21:35:09.936: E/AndroidRuntime(15174): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ochs.androidsnake/com.x.x.MainActivity}: java.lang.NullPointerException
为我工作,谢谢! – user2410644