Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid custom dialog gives an error
    primarykey
    data
    text
    <p>In my <strong>android</strong> app I have to popup a <strong>dialog</strong> on a <strong>button click event</strong>. But when I click on the button the app <strong>stops</strong> working. I load the pre designed layout into the dialog. I will post a code segment.</p> <pre><code>Button login = (Button) findViewById(R.id.btn_login); login.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getApplication()); dialog.setContentView(R.layout.journey_details); dialog.setTitle("Android Custom Dialog Box"); Button dialogButton = (Button) dialog.findViewById(R.id.btn_start_jrny); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); </code></pre> <p>And It shows the following <strong>error</strong> in the <strong>Log cat</strong>.</p> <pre><code> E/AndroidRuntime(1412): FATAL EXCEPTION: main E/AndroidRuntime(1412): Process: com.xont.geotracker, PID: 1412 E/AndroidRuntime(1412): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime(1412): at android.view.ViewRootImpl.setView(ViewRootImpl.java:538) E/AndroidRuntime(1412): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) E/AndroidRuntime(1412): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/AndroidRuntime(1412): at android.app.Dialog.show(Dialog.java:286) E/AndroidRuntime(1412): at com.xont.geotracker.Loging$1.onClick(Loging.java:61) E/AndroidRuntime(1412): at android.view.View.performClick(View.java:4424) E/AndroidRuntime(1412): at android.view.View$PerformClick.run(View.java:18383) E/AndroidRuntime(1412): at android.os.Handler.handleCallback(Handler.java:733) E/AndroidRuntime(1412): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(1412): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime(1412): at android.app.ActivityThread.main(ActivityThread.java:4998) E/AndroidRuntime(1412): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(1412): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime(1412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) E/AndroidRuntime(1412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) E/AndroidRuntime(1412): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Can someone help me to figure out the error. Need help. Thank you!</p>
    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.
 

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