Note that there are some explanatory texts on larger screens.

plurals
  1. POAlertDialog.show() makes my app crash
    primarykey
    data
    text
    <p>here's my problem :</p> <p>I'm trying to show a AlertDialog, but i can't seem to be able to do it.</p> <p>Here's my code :</p> <pre><code>tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { final EditText input = new EditText(c); AlertDialog.Builder adb = new AlertDialog.Builder(c); adb.setTitle(lb) .setMessage("Test") .setView(input) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //tv.setText(input.getEditableText().toString()); Toast.makeText(c, input.getEditableText().toString(), Toast.LENGTH_LONG).show(); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).show(); } }); </code></pre> <p>I want to show this AlertDialog when user click on a label, then change the label value with the edit text one when user press OK.</p> <p>But when it comes to show the dialog on click, it crashes.</p> <pre><code>07-18 16:04:59.240: E/AndroidRuntime(10503): FATAL EXCEPTION: main 07-18 16:04:59.240: E/AndroidRuntime(10503): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.ViewRootImpl.setView(ViewRootImpl.java:710) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:345) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.app.Dialog.show(Dialog.java:277) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.app.AlertDialog$Builder.show(AlertDialog.java:932) 07-18 16:04:59.240: E/AndroidRuntime(10503): at com.technicachat.webdatadomo.Consignes$2$1.run(Consignes.java:114) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.app.Activity.runOnUiThread(Activity.java:4784) 07-18 16:04:59.240: E/AndroidRuntime(10503): at com.technicachat.webdatadomo.Consignes$2.onClick(Consignes.java:90) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.View.performClick(View.java:4211) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.view.View$PerformClick.run(View.java:17267) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.os.Handler.handleCallback(Handler.java:615) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.os.Handler.dispatchMessage(Handler.java:92) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.os.Looper.loop(Looper.java:137) 07-18 16:04:59.240: E/AndroidRuntime(10503): at android.app.ActivityThread.main(ActivityThread.java:4898) 07-18 16:04:59.240: E/AndroidRuntime(10503): at java.lang.reflect.Method.invokeNative(Native Method) 07-18 16:04:59.240: E/AndroidRuntime(10503): at java.lang.reflect.Method.invoke(Method.java:511) 07-18 16:04:59.240: E/AndroidRuntime(10503): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 07-18 16:04:59.240: E/AndroidRuntime(10503): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 07-18 16:04:59.240: E/AndroidRuntime(10503): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Fewer lines before i got this message :</p> <pre><code>07-18 16:04:56.645: I/Choreographer(10503): Skipped 32 frames! The application may be doing too much work on its main thread. </code></pre> <p>I know what it means, but i'm just showing a dialog, it's not this much work !</p> <p>I hope you guys can help me !</p> <p>Bye</p>
    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.
 

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