当前位置:网站首页>Fragment's show and hide
Fragment's show and hide
2022-08-10 13:20:00 【sharp】
package kk.com.yuekao; import android.os.Bundle;import android.support.v4.app.FragmentActivity;import android.support.v4.app.FragmentManager;import android.support.v4.app.FragmentTransaction;import android.widget.RadioGroup; import com.bawei.fragment.Fragment1;import com.bawei.fragment.Fragment2;import com.bawei.fragment.Fragment3; public class MainActivity extends FragmentActivity {private RadioGroup group;private Fragment1 fragment1;private Fragment2 fragment2;private Fragment3 fragment3;private FragmentTransaction transactiontransaction;private FragmentManager supportFragmentManager; @Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//Get the resource IDgroup=findViewById(R.id.group);//Method of loading Fragment//get the management classsupportFragmentManager = getSupportFragmentManager();fragment1 = new Fragment1();fragment2 = new Fragment2();fragment3 = new Fragment3();//Open thingstransactiontransaction = supportFragmentManager.beginTransaction();//Load Fragmenttransactiontransaction.add(R.id.fragm,fragment1);transactiontransaction.add(R.id.fragm,fragment2);transactiontransaction.add(R.id.fragm,fragment3);// show and hidetransactionransaction.show(fragment1).hide(fragment2).hide(fragment3);transactiontransaction.commit();group.check(group.getChildAt(0).getId()); //group monitorgroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {FragmentTransaction FragmentTransaction1= supportFragmentManager.beginTransaction();switch (checkedId){case R.id.but1:fragmentTransaction1.show(fragment1).hide(fragment2).hide(fragment3);break;case R.id.but2:fragmentTransaction1.show(fragment2).hide(fragment1).hide(fragment3);break;case R.id.but3:fragmentTransaction1.show(fragment3).hide(fragment2).hide(fragment1);break;} } }fragmentTransaction1.commit();} }});} }}
————————————————
版权声明:本文为CSDN博主「Fahaxiki丿」的原创文章,遵循CC 4.0 BY-SACopyright agreement, reprint please attach the original source link and this statement.
Original link: https://blog.csdn.net/wangshuo_/article/details/86229990
边栏推荐
- Codeforces Round #276 (Div. 1) B. Maximum Value
- 【iOS】Organization of interviews
- 【数字IC验证进阶】SoC系统验证和IP模块验证的区别及侧重点分析
- 22家!北京昌平区通报存在食品安全问题餐饮服务企业
- 「网络架构」网络代理第一部分: 代理概述
- 3DS MAX 批量导出文件脚本 MAXScript 带界面
- 关于flask中static_folder 和 static_url_path参数理解
- Comparison version number of middle questions in LeetCode
- 娄底妆品实验室建设规划构思
- 金山云要飘到哪里?
猜你喜欢

shell:正则表达式及三剑客grep命令

【百度统计】用户行为分析

漏洞管理计划的未来趋势

Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs

百度用户产品流批一体的实时数仓实践
![ArcMAP has a problem of -15 and cannot be accessed [Provide your license server administrator with the following information:Err-15]](/img/da/b49d7ba845c351cefc4efc174de995.png)
ArcMAP has a problem of -15 and cannot be accessed [Provide your license server administrator with the following information:Err-15]

Basic knowledge of switches
![ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]](/img/da/b49d7ba845c351cefc4efc174de995.png)
ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]

LeetCode中等题之搜索二维矩阵

Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing
随机推荐
H264 码率控制
专有云ABC Stack,真正的实力派!
Codeforces Round #276 (Div. 1) D. Kindergarten
MYSQL误删数据恢复
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
Shell:数组
shell:常用小工具(sort、uniq、tr、cut)
C# error The 'xmins' attribute is not supported in this context
DNS欺骗-教程详解
百度用户产品流批一体的实时数仓实践
Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing
Reversing words in a string in LeetCode
Network Saboteur
生成树协议STP(Spanning Tree Protocol)
odps sql 不支持 unsupported feature CREATE TEMPORARY
MySQL面试题整理
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
Loudi Cosmetics Laboratory Construction Planning Concept
想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
C#中导入其它自定义的命名空间