I am developing a simple android app that has a widget with a button that when pressed will just display an AlertDialog which has some text. There are no errors showing for my code in the IDE. When I click the widgets button a menu pops up saying "One UI Home keeps stopping" and then gives me options to send feedback to android and close the app. I have absolutely no idea what is happening here, I am very new to creating Android apps.
Widgets XML file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#09C"
android:padding="@dimen/widget_margin">
<Button
android:id="@+id/getButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="AlertUser"
android:text="@string/button_text" />
</RelativeLayout>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void AlertUser(View view) {
new AlertDialog.Builder(getApplicationContext())
.setTitle("Keycode")
.setMessage("Test")
// A null listener allows the button to dismiss the dialog and take no further action.
.setNegativeButton(android.R.string.no, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
All other files have been kept as default. Any help appreciated!