I have been trying for a while to remove the title of a DialogFragment, but several attempts have failed. I tried with these:
<style name="dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
and this:
int style, theme;
style = DialogFragment.STYLE_NO_TITLE;
theme = R.style.dialog;//Tried using Theme.Holo.Dialog here too
setStyle(style, theme);//Setting theme to 0 renders it invisible. Content only
And this(has no effect):
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// request a window without the title
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
None have an effect in removing the title.
Any other ideas?
EDIT:
Important code in the DIalogFragment:
public class MenuDialog extends DialogFragment implements View.OnClickListener {
Context c;
Clicker cl;
Game game;
public static MenuDialog newInstance() {
MenuDialog f = new MenuDialog();
// Supply num input as an argument.
Bundle args = new Bundle();
f.setArguments(args);
return f;
}
public void params(Context c, Clicker cl, Game game){
this.c = c;
this.cl = cl;
this.game = game;
}
@Override
public void onCreate(Bundle sis){
super.onCreate(sis);
int style, theme;
style = DialogFragment.STYLE_NO_TITLE;
theme = R.style.dialog;//This theme is as defined above
setStyle(style, theme);
}
private View v;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.menu, container, false);
this.v = v;
setButtons();
return v;
}
}
Displaying the dialog:
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment prev = getFragmentManager().findFragmentByTag("dialog");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
MenuDialog newFragment = MenuDialog.newInstance();
newFragment.params(getBaseContext(), clicker, this);
newFragment.show(ft, "dialog");