Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Null Pointer,where shoud I put the code for activity?
    primarykey
    data
    text
    <p>I set a swith card with three tab in the main activity,there is a listview in the third tab,click the listview will pop up time options dialog box.</p> <pre><code>public void onSetWarn(){ LayoutInflater factoryInflater = LayoutInflater.from(MainActivity.this); final View dialogView = factoryInflater.inflate(R.layout.dialog, null); AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).setTitle("set") .setView(dialogView) .setPositiveButton("confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), "set success!", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create(); /* timePicker = (TimePicker) this.findViewById(R.id.TimePicker1); timePicker.setIs24HourView(true); */ dialog.show(); } </code></pre> <p>where should i put this code</p> <pre><code>timePicker = (TimePicker) this.findViewById(R.id.TimePicker1); timePicker.setIs24HourView(true); </code></pre> <p>I trid several places,but all the NULL pointer errors.</p> <p>dialog.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="reminder the time" /&gt; &lt;TimePicker android:id="@+id/TimePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="remind way" /&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;CheckBox android:id="@+id/checkBox1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="ring" /&gt; &lt;CheckBox android:id="@+id/checkBox2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="shake" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    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.
    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