2

I'd like to show an Alert Dialog which does not hide action bar. Is it possible to do it? The code which I tried is:

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle("Basemap selection");
    builder.setSingleChoiceItems(new String[]{"Create cache", "Use existing file"}, 0, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Some logic here.
        }
    });
    builder.setNegativeButton(R.string.common_cancel, null);
    builder.create().show();

It covers the whole screen but I need the action bar to be available while dialog is showing. I know that it might violate some android rules but UX department wants it. The screenshot is:enter image description here

Eduard Lepner
  • 639
  • 6
  • 17
  • Post your code what u tried? – M D Jun 23 '14 at 05:19
  • one option is to make the activity to alert dialogue. its simple create a activity and go to manifest and set the activity theme as @android:style/Theme.DeviceDefault.Dialog – Nithinlal Jun 23 '14 at 05:19
  • 1
    What do you mean by this? When you show an Alert Dialog, it will appear above the current Activity - is the Activity Action Bar what you want to hide/show? Or do you want to show the Action Bar in the dialog's view itself? – Eric Brynsvold Jun 23 '14 at 05:20
  • You may implement dialog as activity for the same, with this you can show the action bar. – Karioki Jun 23 '14 at 05:34
  • @ shylendra how is it possible ? – Nithinlal Jun 23 '14 at 05:36
  • "You may implement dialog as activity for the same" - yes I can but a user needs to ineract with map sometimes. In this case I need to maintain action bar in 2 activities. – Eduard Lepner Jun 23 '14 at 05:44

2 Answers2

1

If you want to make a non-modal dialog (allowing the user to tap outside the dialog and access the Action Bar while the dialog is visible), there's some information here that may be helpful: timed modeless dialog, specifically the use of dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); - called after your dialog is visible.

Community
  • 1
  • 1
Eric Brynsvold
  • 2,880
  • 3
  • 17
  • 22
0

The option is to change the activity to the Dialogue.Its simple process create an activity and goes to manifest file and set the theme of activity as

@android:style/Theme.DeviceDefault.Dialog
Nithinlal
  • 4,845
  • 1
  • 29
  • 40
  • I tried, it does not work, maybe I've done something wrong. The code is – Eduard Lepner Jun 23 '14 at 05:40
  • u have to create a new activity for the dialogue example:BaseMap Selection.java, change the theme in this activity to the @android:style/Theme.DeviceDefault.Dialog. when u want show popup, u have to call the activity by using intent – Nithinlal Jun 23 '14 at 05:45
  • Aaah. Do you want to say that this new activity will not hide action bar of the previous one? – Eduard Lepner Jun 23 '14 at 05:48
  • yes. This is the way.The dialogue comes over the activity. Other wise u have to create a custom dialogue. – Nithinlal Jun 23 '14 at 05:52