下面列出了android.support.v4.app.DialogFragment#setStyle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createLoginDialog() {
if (!isFinishing() && !isDestroyed()) {
DialogFragment fragment = LoginDialogFragment.newInstance();
fragment.setCancelable(false);
fragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(fragment, getString(R.string.title_login));
fragmentTransaction.commitAllowingStateLoss();
}
}
@Override
// from ItemFragment
public void onListItemClickFragmentInteraction(Item item) {
DialogFragment myDialog = ItemActionListFragment.newInstance(item.getItemId().toString());
// for API >= 23 the title is disable by default -- we set a style that enables it
myDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.ItemActionListDialogFragment);
myDialog.show(getSupportFragmentManager(), getString(R.string.item_action_list_dialog_fragment_tag));
}
@Override
// from ItemActionListFragment
public void onEditItemAction(int id) {
// get item from database
ItemHelper itemHelper = ItemHelper.getInstance(getApplicationContext());
Item itemToUpdate = itemHelper.get(id);
if(itemToUpdate != null) {
DialogFragment myDialog = AddItemDialogFragment.newInstance(id, itemToUpdate.getName(), itemToUpdate.getAmount());
// for API >= 23 the title is disable by default -- we set a style that enables it
myDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.AddItemDialogFragment);
myDialog.show(getSupportFragmentManager(), getString(R.string.add_item_dialog_fragment_tag));
}
}
private void showDialogDetail() {
String out = getDataOutput();
DialogFragment newFragment = DetailedDataFragment.newInstance(out);
newFragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
newFragment.show(getSupportFragmentManager(), "dialog");
}
private void showAbout() {
DialogFragment myDialog = AboutFragment.newInstance();
// for API >= 23 the title is disable by default -- we set a style that enables it
myDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.AboutFragment);
myDialog.show(getSupportFragmentManager(), getString(R.string.about_fragment_tag));
}
private void getNewItemDetails() {
DialogFragment myDialog = AddItemDialogFragment.newInstance(-1, "", 0);
// for API >= 23 the title is disable by default -- we set a style that enables it
myDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.AddItemDialogFragment);
myDialog.show(getFragmentManager(), getString(R.string.add_item_dialog_fragment_tag));
}