In the XML my MainActivity , I programmed it to use a theme with a NoActionBar and therefore the action bar does not appear. However, whenever I want to display a dialog, I call one of my DialogFragments , which uses AlertDialog.Builder to create the dialog. When I show the dialog from the main action, it shows the dialog with the ActionBar . When I close the dialog box , the action bar remains .
QUESTION How can I align and hide the action bar when the fragment disappears or does not appear in the first place?
I tried to create my own style and then wrap it in ContextThemeWrapper no avail.
getActionBar().hide() and getSupportActionBar().hide() returns null for both the main action and the fragment.
myDialog.getDialog() in MainActivity (before calling .show() ) returns null .
The code I used to create AlertDialog.Builder is inside DialogFragment onCreateDialog :
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.delete_confirmation) .setItems(fileSequence, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { File loadedFile = fileFullArray.get(which); boolean deleted = loadedFile.delete(); if (deleted) Toast.makeText(getActivity().getApplicationContext(), "File deleted!", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {
EDIT:
Reverted to this 4 months later, and the patch added the following line in the onCreate() dialog:
this.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
The onCreate() fragment was a rewrite written in MainActivity . Greetings.