当前位置:网站首页>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
边栏推荐
- Comparison version number of middle questions in LeetCode
- C#报错 The ‘xmins‘ attribute is not supported in this context
- 「网络架构」网络代理第一部分: 代理概述
- 10 款更先进的开源命令行工具
- 山水的高度
- 海外邮件发送指南(二)
- 神经网络可视化有3D版本了,美到沦陷!(已开源)
- 浙大、阿里提出DictBERT,字典描述知识增强的预训练语言模型
- 3DS MAX batch export file script MAXScript with interface
- 22家!北京昌平区通报存在食品安全问题餐饮服务企业
猜你喜欢
Reversing words in a string in LeetCode
Real-time data warehouse practice of Baidu user product flow and batch integration
商汤自研机械臂,首款产品是AI下棋机器人:还请郭晶晶作代言
Open Office XML 格式里如何描述多段具有不同字体设置的段落
BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection 论文笔记
10 款更先进的开源命令行工具
【ECCV 2022|百万奖金】PSG大赛:追求“最全面”的场景理解
“68道 Redis+168道 MySQL”精品面试题(带解析)
燃炸!字节跳动成功上岸,只因刷爆LeetCode算法面试题
瑞幸「翻身」?恐言之尚早
随机推荐
OTA自动化测试解决方案---整体方案介绍
22家!北京昌平区通报存在食品安全问题餐饮服务企业
“68道 Redis+168道 MySQL”精品面试题(带解析)
Prada, big show?In the yuan in the universe that!
11 + chrome advanced debugging skills, learn to direct efficiency increases by 666%
I would like to ask the big guys, how to solve this error when cdc oracle initializes a 3 million table task running
LeetCode中等题之搜索二维矩阵
【百度统计】用户行为分析
把相亲角搬到海外,不愧是咱爸妈
Fragment的show和hide
10 款更先进的开源命令行工具
LeetCode中等题之颠倒字符串中的单词
Redis 定长队列的探索和实践
百度用户产品流批一体的实时数仓实践
讯飞创意组别 全国选拔赛成绩公布说明
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
ArcMAP has a problem of -15 and cannot be accessed [Provide your license server administrator with the following information:Err-15]
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
想通这点,治好 AI 打工人的精神内耗
机器学习实战(2)——端到端的机器学习项目