fragment的开发记录
来源:互联网 发布:mysql忘记密码怎么办 编辑:程序博客网 时间:2024/06/06 04:04
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">最新由于开发过程中,产品不断的提出新的界面改动,导致安卓开发的代码一直改动。不说多的上图。</span>
这个做成两个fragment,用fragmentmanager开启事物,进行
FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();transaction.replace(R.id.framelayout,fragment1);transaction.commit;
这种做法就是第一幅图片也做成fragment,用fragmentManager进行切换,但是这个界面做成fragment之后,第一个界面是刷卡的界面,需要加载后台的service初始化,还有需要绑定service,需要在activity里面写一个onnewintent方法用于nfc后台的service读取数据,fragment里面无法写这些方法,还有service需要在activity销毁的时候解除绑定,这就是说第一个界面需要在activity里面写入,于是乎将第二图做成fragment,点击上面的有卡认证和无卡认证进行颜色修改,和fragment的现实和隐藏
case R.id.ll_card: tv_card.setTextColor(Color.parseColor("#0174e1")); view_card.setVisibility(View.VISIBLE); tv_nocard.setTextColor(Color.parseColor("#000000")); view_nocard.setVisibility(View.GONE); transaction=getSupportFragmentManager().beginTransaction(); transaction.hide(nocardFragment); transaction.commit(); break; case R.id.ll_nocard: transaction=getSupportFragmentManager().beginTransaction(); tv_nocard.setTextColor(Color.parseColor("#0174e1")); view_nocard.setVisibility(View.VISIBLE); tv_card.setTextColor(Color.parseColor("#000000")); view_card.setVisibility(View.GONE); if(nocardFragment.isHidden()){ transaction.show(nocardFragment); } transaction.replace(R.id.frame_auth,nocardFragment); transaction.commit(); break;
这里view_nocard和view_card是那块3dp高的绿色部分,这里第一次加载fragment需要在用
case R.id.ll_card: tv_card.setTextColor(Color.parseColor("#0174e1")); view_card.setVisibility(View.VISIBLE); tv_nocard.setTextColor(Color.parseColor("#000000")); view_nocard.setVisibility(View.GONE); transaction=getSupportFragmentManager().beginTransaction(); transaction.hide(nocardFragment); transaction.commit(); break;case R.id.ll_nocard: transaction=getSupportFragmentManager().beginTransaction(); tv_nocard.setTextColor(Color.parseColor("#0174e1")); view_nocard.setVisibility(View.VISIBLE); tv_card.setTextColor(Color.parseColor("#000000")); view_card.setVisibility(View.GONE); if(nocardFragment.isHidden()){ transaction.show(nocardFragment); } transaction.replace(R.id.frame_auth,nocardFragment); transaction.commit(); break;这里view_nocard和view_card是那块3dp高的绿色部分,这里第一次加载fragment需要在用
transaction.replace(R.id.frame_auth,nocardFragment);加载这个fragment覆盖帧布局下面的,然后点击有卡认证需要隐藏该fragment,当再次点击显示该fragment,不能继续用replace方法,这个方法无效因为隐藏了就无法现实。
于是本人试了用add(fragment),和remove方法,但是这个方法在用户点击两次无卡认证的时候会add两次直接导致崩溃。需要判断该fragment是否显示is hidden表示如果该fragment隐藏就show显示,然后就可以实现该fragment和activy一部分界面之间的切换。
楼主在以为已经全美实现该功能的时候,测试过程中发现了一个bug,就是点击上面的fragment的空白处,出点到下面覆盖掉的activity的checkbox控件,为了解决这个问题,当然可以把下面布局的checkbox位置修改,或者把上面fragment的空白加上图片之类的有控件就不会点击到下面的页面,但是改方法明显治标不治本。
后来查看资料,需要在fragment里面给整个fragment设置点击事件,来组织事件向下传递。
需要在fragment的onCreateView方法中添加
view.setOnClickListener(null);这个方法就可以阻止点击到下面的布局。
0 0
- fragment的开发记录
- fragment的一些记录
- 记录一些fragment的知识点
- Fragment的一个生命周期记录
- 关于fragment滑动的记录
- Fragment记录
- Fragment 使用时的崩溃记录
- Fragment 生命周期的一点点个人记录
- Fragment 生命周期的onResume 问题记录
- 记录下自己的android知识--Fragment
- Android开发fragment的使用
- Fragment生命周期到项目开发使用Fragment的抽取
- 记录开发的点点滴滴
- shuipFCMS的开发记录
- android开发的记录
- ViewPager里的Fragment的广播监听问题记录
- 记录Fragment生命周期
- 记录使用fragment
- js如何获取上个月第一天和最后一天
- Linux内核访问外设I/O资源的方式
- TCP 一端关闭,另一端调用send进程退出了
- 批量删除table或view
- 转义字符与特殊字符
- fragment的开发记录
- Hdu 5650 so easy (BestCoder Round #77 (div.2 A))
- apache安装
- 【OpenCV】OpenCV的类型转换问题(BYTE、IplImage、Mat等)
- MySQL中SELECT+UPDATE处理并发更新问题解决方案分享
- 如何利用百科实现推广好效果
- 懒加载 warning: could not load any Objective-C class information. This will significantly reduce the qu
- 核密度估计-Kernel density estimation--精华汇总
- myBatis 使用Select top 动态参数出现“´@P0´ 附近有语法错误”的解决