Comment faire DialogFragment modal?
J'ai un DialogFragment :
public static class CharacteristicDialog extends DialogFragment {
int mNum;
static CharacteristicDialog newInstance(int num) {
CharacteristicDialog f = new CharacteristicDialog();
Bundle args = new Bundle();
args.putInt("num", num);
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNum = getArguments().getInt("num");
setStyle(STYLE_NO_INPUT, 0);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.characteristic_dialog, container, false);
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
J'ai créer dans mon principal Fragment comme ceci :
DialogFragment newFragment = CharacteristicDialog.newInstance(v.getId());
newFragment.setShowsDialog(true);
newFragment.show(getFragmentManager(), "dialog");
Il montre bien, mais il n'est pas modale (je peux cliquer sur les côtés et faire des actions sur mon principal Fragment derrière la boîte de dialogue).
Comment puis-je faire modal ?
Grâce
I can click on the sides and make actions on my main Fragment behind the dialog
Qui sonne vraiment bizarre... Êtes-vous à l'aide de natif de fragments ou de la bibliothèque de prise en charge? Actionbarsherlock?- Je suis avec le soutien de la lib, pas de Actionbarsherlock.
Vous devez vous connecter pour publier un commentaire.
Il suffit de changer
STYLE_NO_INPUT
тоSTYLE_NORMAL
dans votresetStyle()
méthode.Pour plus d'informations sur DialogFragment de styles et de thèmes prenez regarder les docs:
http://developer.android.com/reference/android/app/DialogFragment.html
Cela a fonctionné pour moi.