Note that there are some explanatory texts on larger screens.

plurals
  1. PODialog with Button and onClick Listener throws exception
    primarykey
    data
    text
    <p>I coded a Dialog that shows up with 2 textviews and 2 buttons. I googled for that Problem as well but I didn't find anything that mathced my issue. Here is some Code:</p> <pre><code>case R.id.open: openDialog=new Dialog(this); openDialog.setContentView(R.layout.open_dialog); openDialog.setTitle(head); openDialog.setCancelable(true); Button open_cancel=(Button)findViewById(R.id.open_cancel); open_cancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { openDialog.cancel(); } }); </code></pre> <p>but I can't show the dialog up with the buttons. If I call it without these Lines there is no Problem:</p> <pre><code> Button open_cancel=(Button)findViewById(R.id.open_cancel); open_cancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { openDialog.cancel(); } }); </code></pre> <p>This is the XML File:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/open_dialog" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" &gt; &lt;EditText android:id="@+id/open_head" android:layout_width="fill_parent" android:layout_height="50dp" android:text="ojfpojew ojr pojr" /&gt; &lt;EditText android:id="@+id/open_note" android:layout_width="fill_parent" android:text="oijpojepojpotjpotejpe ojtpojtpo ewpoj tpojt pp jpojtpoj etpoj poj poj t" android:layout_height="150dp" /&gt; &lt;Button android:id="@+id/open_edit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="edit" /&gt; &lt;Button android:id="@+id/open_cancel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="cancel" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I really do not understand why this not works... here is the error log, if it helps:</p> <pre><code>01-05 16:43:51.004: D/dalvikvm(2336): GC freed 1010 objects / 70136 bytes in 75ms 01-05 16:43:51.204: D/dalvikvm(2336): GC freed 91 objects / 3664 bytes in 53ms 01-05 16:43:51.494: D/dalvikvm(2336): GC freed 132 objects / 6240 bytes in 62ms 01-05 16:43:51.674: D/dalvikvm(2336): GC freed 58 objects / 2312 bytes in 56ms 01-05 16:43:51.944: D/dalvikvm(2336): GC freed 147 objects / 9128 bytes in 63ms 01-05 16:43:52.383: D/ViewFlipper(2336): updateRunning() mVisible=true, mStarted=false, mUserPresent=true, mRunning=false 01-05 16:44:00.973: D/dalvikvm(2336): GC freed 25495 objects / 1393728 bytes in 88ms 01-05 16:44:02.644: D/dalvikvm(2336): GC freed 45722 objects / 2044568 bytes in 102ms 01-05 16:44:04.424: I/Resources(2336): Loaded time zone names for en in 1591ms. 01-05 16:44:06.834: D/dalvikvm(2336): GC freed 36788 objects / 1674624 bytes in 102ms 01-05 16:44:11.243: D/AndroidRuntime(2336): Shutting down VM 01-05 16:44:11.263: W/dalvikvm(2336): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 01-05 16:44:11.263: E/AndroidRuntime(2336): Uncaught handler: thread main exiting due to uncaught exception 01-05 16:44:11.273: E/AndroidRuntime(2336): java.lang.NullPointerException 01-05 16:44:11.273: E/AndroidRuntime(2336): at producteev.push.Producteev_pushActivity.onContextItemSelected(Producteev_pushActivity.java:247) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.app.Activity.onMenuItemSelected(Activity.java:2174) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2731) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:129) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:884) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.widget.ListView.performItemClick(ListView.java) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.os.Handler.handleCallback(Handler.java:587) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.os.Handler.dispatchMessage(Handler.java:92) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.os.Looper.loop(Looper.java:123) 01-05 16:44:11.273: E/AndroidRuntime(2336): at android.app.ActivityThread.main(ActivityThread.java:4363) 01-05 16:44:11.273: E/AndroidRuntime(2336): at java.lang.reflect.Method.invokeNative(Native Method) 01-05 16:44:11.273: E/AndroidRuntime(2336): at java.lang.reflect.Method.invoke(Method.java:521) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 01-05 16:44:11.273: E/AndroidRuntime(2336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 01-05 16:44:11.273: E/AndroidRuntime(2336): at dalvik.system.NativeStart.main(Native Method) 01-05 16:44:11.293: I/dalvikvm(2336): threadid=7: reacting to signal 3 01-05 16:44:11.323: I/dalvikvm(2336): Wrote stack trace to '/data/anr/traces.txt' 01-05 16:44:13.383: I/Process(2336): Sending signal. PID: 2336 SIG: 9 </code></pre>
    singulars
    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