DialogFragment
来源:互联网 发布:h5棋牌游戏源码论坛 编辑:程序博客网 时间:2024/06/10 04:01
今天在自定义对话框的时候里面的内容用fragment来写,但是无法替换里面的fragment。
错误码如下:
No view found for id 0x7f09003a (com.doimob.sysale:id/ccc) for fragment GoodsFragment{b061447 #0 id=0x7f09003a goodsFragment}
本来想在dialog里面(嵌套)替换fragment,但是发现一个大大的bug。 就是都找不到framelayout的 id 。 最后在网上发现使用dailogfragment 是一种特殊的dialog。然后就可以替换使用fragment。
1 DialogFragment是一种功能特殊的对话框 当对话框存在fragment的时候使用此对话框
2 设置对话框的宽度和高度要在onActivityCreate之后设置
Window window = getDialog().getWindow(); WindowManager windowManager = window.getWindowManager(); Display d = windowManager.getDefaultDisplay(); // 获取屏幕宽、高用 WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值 p.height = (int) (d.getHeight() * 0.8); // 高度设置为屏幕的0.8 p.width = (int) (d.getWidth() * 1); // 宽度设置为屏幕的1 window.setLayout(p.width, p.height);/*Window window = getDialog().getWindow(); WindowManager.LayoutParams attributes = window.getAttributes(); window.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#88838B8B"))); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);*/
具体 dialogfragment的使用请看鸿洋大神的:
http://blog.csdn.net/lmj623565791/article/details/37815413
0 0
- DialogFragment
- dialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- dialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- Android DialogFragment
- 使用DialogFragment
- DialogFragment学习
- dialogfragment使用
- PPT中Flash动画路径错误导致无法播放
- java微信开发---jsapi接口授权和解绑设备
- MySql笔记【持续更新】
- maven安装入门
- RandomAccessFile 读取
- DialogFragment
- Java中关于字符串转成毫秒数以及毫秒数转化成字符串的总结
- 从0开始学习 GitHub 系列之「加入 GitHub」
- C++:用CreateDirectory创建文件目录
- [整体二分 树状数组套线段树] BZOJ 2674 Attack
- JedisRedirectionException:Too many Cluster redirections
- java异常记录集
- 分布式一致性算法:paxos
- Java并发编程之——CountDownLatch的使用