public class YesNoDialog extends DialogFragment
{
public YesNoDialog()
{
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
Bundle args = getArguments();
String title = args.getString("title", "");
String message = args.getString("message", "");
return new AlertDialog.Builder(getActivity())
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, null);
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED, null);
}
})
.create();
}
}
DialogFragment dialog = new YesNoDialog();
Bundle args = new Bundle();
args.putString("title", title);
args.putString("message", message);
dialog.setArguments(args);
dialog.setTargetFragment(this, YES_NO_CALL);
dialog.show(getFragmentManager(), "tag");
第二种:
转自
http://blog.csdn.net/lmj623565791/article/details/37815413
分享到:
相关推荐
相关博客:【android学习开源项目之AndroidAutoSize】AndroidAutoSize和DialogFragment的适配 https://blog.csdn.net/ljb568838953/article/details/103906449; 本demo的知识点:1.AndroidAutoSize 的使用(今日...
类似PopupWindow的弹框DialogFragment实现TabLayout+ViewPager多个Fragment左右滑动切换
Google官方推荐使用DialogFragment代替AlertDialog,很好的解决屏幕旋转产生的问题。。。
DialogFragment实现底部弹窗 DialogFragment底部弹窗的开发模板,Created by C.L. Wang
DialogFragment的使用及利用自定义interface点击事件并解决旋转屏幕点击事件失效问题
对dialogFragment进行封装,包装。并对弹窗进行统一管理。包含弹窗的c++语言的背景模糊调用,dialog消亡后,内存的快速回收,提高效率。统一处理dissmiss事件。方便复杂的dialog功能需求。 调用方式 application中 ...
demo中讲解了各种Dialogfragment功能
Android中基于DialogFragment实现的Dialog提示功能,附加了nice的动画效果。
Android DialogFragment的使用方法 ,google官方推荐使用DialogFragment代替Dialog. 具体的详细解释可以在我的博客http://blog.csdn.net/a253664942/article/details/45585661中看看,有问题的可以我给留言!
android当中DialogFragment的简单使用,配合博客的代码
使用建造者模式、dialogfragment、recycleView自定义列表式的dialog
blog原文 http://blog.csdn.net/qiaoidea/article/details/46402845 讲解分析 Dialog 和DialogFragment
使用dialogfragment加载多张图片
使用自定义dialogfragment 实现底部弹出框分享的效果
android 自定义dialogfragment全屏对话窗体,这个demo还是很棒的。值得学习,直接用在项目里。
dialog 封装DialogFragment来实现的, 通用dialog 弹框.底部弹框,分享弹框
一个自定义的dialog,其实只是继承了dialogfragment,博客地址为http://blog.csdn.net/u013651405/article/details/47834057
react native 弹出框,类似android的DialogFragment