Note that there are some explanatory texts on larger screens.

plurals
  1. POLaunching a Custom Dialog
    primarykey
    data
    text
    <p>I've followed the Android Documentation on creating a custom dialog. When I click the button that launches my custom dialog the app. crashes. How do I begin to troubleshoot this?</p> <p>The dialog: </p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout1" android:gravity="center_vertical" android:layout_height="wrap_content" android:layout_width="fill_parent"&gt; &lt;CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/chkBlueTooth" android:id="@+id/chkBlueTooth" android:layout_below="@+id/chkAudio" android:layout_alignLeft="@+id/chkAudio"&gt;&lt;/CheckBox&gt; &lt;Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_below="@+id/chkBlueTooth" android:layout_alignLeft="@+id/chkBlueTooth" android:id="@+id/btnOK" android:text="@string/btnOK"&gt;&lt;/Button&gt; &lt;CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/chkNetwork" android:id="@+id/chkNetwork" android:layout_above="@+id/chkBlueTooth" android:layout_toRightOf="@+id/chkBlueTooth"&gt;&lt;/CheckBox&gt; &lt;CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/chkWifi" android:id="@+id/chkWifi" android:layout_below="@+id/chkNetwork" android:layout_alignLeft="@+id/chkNetwork" android:layout_alignRight="@+id/chkNetwork"&gt;&lt;/CheckBox&gt; &lt;CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/chkAudio" android:id="@+id/chkAudio" android:layout_below="@+id/txtChoose" android:layout_alignLeft="@+id/txtChoose"&gt;&lt;/CheckBox&gt; &lt;/RelativeLayout&gt; </code></pre> <p>The Code for the dialog: static final int TIME_DIALOG_ID = 0; static final int POWER_OFF_OPTIONS = 1;</p> <p>@Override protected Dialog onCreateDialog(int id) { Dialog dialog; switch (id) { case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mHour24, mMinute, false);</p> <pre><code> case POWER_OFF_OPTIONS: AlertDialog.Builder builder; AlertDialog alertDialog; Context mContext = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.options, (ViewGroup)findViewById(R.id.relativeLayout1)); //Capture view elements mChkAudio = (CheckBox) findViewById(R.id.chkAudio); mChkBluetooth = (CheckBox) findViewById(R.id.chkBlueTooth); mChkNetwork = (CheckBox) findViewById(R.id.chkNetwork); mChkWifi = (CheckBox) findViewById(R.id.chkWifi); mBtnOK = (Button) findViewById(R.id.btnOK); mBtnOK.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { DismissPowerOptions(); } }); builder = new AlertDialog.Builder(mContext); builder.setView(layout); alertDialog = builder.create(); //return builder; default: dialog = null; } return dialog; } </code></pre> <p>The Button that shows the dialog and crashes the app:</p> <pre><code> mBtnPowerOffOptions.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //stuff for Options dialog showDialog(POWER_OFF_OPTIONS); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload