3

I am facing this weird issue.

I have an alert dialog with setPossitiveButton, but it doesn't shows on Nexus 5, only the message part shows up. I tried with neutral button also.

I verified this on another device of my friend (not nexus 5), and its working there too.

Is there something wrong with it ?

Below is the code:

new AlertDialog.Builder(this)
               .setMessage(R.string.no_result)
               .setCancelable(true)
               .setOnCancelListener(new DialogInterface.OnCancelListener() {
                   @Override
                   public void onCancel(DialogInterface dialog) {
                       dialog.dismiss();
                       finish();
                   }})
               .setNeutralButton(R.string.search_again, new DialogInterface.OnClickListener() {
                   @Override
                   public void onClick(DialogInterface dialog, int which) {
                            finish();
                   }})
               .show();
Sergei Bubenshchikov
  • 5,275
  • 3
  • 33
  • 60
viv
  • 6,158
  • 6
  • 39
  • 54
  • have you check your style.xml? may be there is issue with dialogue theme. – KDeogharkar Mar 30 '16 at 05:13
  • @KDeogharkar I am not able to understand how that will interfere with this. Any example ? – viv Mar 30 '16 at 05:19
  • are you using support `AlertDialog` or `app.AlertDialog` ? – Shree Krishna Mar 30 '16 at 05:21
  • @ShreeKrishna : android.app.AlertDialog – viv Mar 30 '16 at 05:23
  • do you mean `search_again` is not showing ? it is showing in my nexus 5. with same code. – Shree Krishna Mar 30 '16 at 05:28
  • @ShreeKrishna : Yes its not showing. Try this app: https://play.google.com/store/apps/details?id=instore.rapido – viv Mar 30 '16 at 05:33
  • @ShreeKrishna : Enter some long random text, so that you don't find any search result, you will see a pop up then. – viv Mar 30 '16 at 05:34
  • It's my emulator actually. But as you told it's working fine in other devices. And as your situation Message is showing but button is not showing is it ? – Shree Krishna Mar 30 '16 at 05:47
  • @ShreeKrishna : Yes, its happening on my client device, which is Nexus 5, on one of my friend Nexus 4, its fine. – viv Mar 30 '16 at 05:51
  • It's a really complex issue, But what I want to suggest is first try `AlertDialog` from support library, second setPositiveButton before others and 3rd is Just create an instance of `AlertDialog.Builder` and create it again before showing like here... `AlertDialog dialog1 = dialog.create();` `dialog1.show();` I know it's same and won't make vast different but, Try once. Miner things may be solved with miner changes. – Shree Krishna Mar 30 '16 at 06:26
  • 1
    ok I will try support library also – viv Mar 30 '16 at 06:30
  • Updating after a long time, but it worked with support library. Looks like old package is broken now. – viv Apr 24 '16 at 18:42

0 Answers0