单击按钮时应用程序崩溃。有一个NullPointerException错误,我该如何解决?
崩溃按钮的XML文件
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clickaqui"
android:id="@+id/registro"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:onClick="onRegister"/>
AndroidManifest:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".CreateMessageActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActvity"
android:label="@string/app_name">
</activity>
</application>
崩溃按钮的代码:
Intent intent = new Intent(CreateMessageActivity.this, RegisterActvity.class);
startActivity(intent);