当前位置:网站首页>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
边栏推荐
- BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection Paper Notes
- LeetCode medium topic search of two-dimensional matrix
- MySQL索引的B+树到底有多高?
- Have you guys encountered this problem?MySQL 2.2 and 2.3-SNAPSHOT are like this, it seems to be
- LeetCode中等题之搜索二维矩阵
- kubernetes介绍
- 想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
- 海外邮件发送指南(二)
- 【目标检测】小脚本:提取训练集图片与标签并更新索引
- wirshark 常用操作及 tcp 三次握手过程实例分析
猜你喜欢
百度用户产品流批一体的实时数仓实践
漏洞管理计划的未来趋势
在web页面播放rtsp流视频(webrtc)
Redis上云迁移实践
LeetCode简单题之合并相似的物品
iTextSharp操作PDF
一个 CRM One Order Application log 的单元测试报表
海外邮件发送指南(二)
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes
Wirshark common operations and tcp three-way handshake process example analysis
随机推荐
Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing
金山云要飘到哪里?
mSystems | 中农汪杰组揭示影响土壤“塑料际”微生物群落的机制
Nanodlp v2.2/v3.0 light curing circuit board, connection method of mechanical switch/photoelectric switch/proximity switch and system state level setting
A detailed explanation of implementation api embed
G1和CMS的三色标记法及漏标问题
DNS欺骗-教程详解
【论文+代码】PEBAL/Pixel-wise Energy-biased Abstention Learning for Anomaly Segmentation on Complex Urban Driving Scenes(复杂城市驾驶场景异常分割的像素级能量偏置弃权学习)
啥?他一个人写了个价值100万的软件,却用来开源了!
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection Paper Notes
bgp双平面实验 路由策略控制流量
【学习笔记】Redis的持久化
11+ chrome高级调试技巧,学会效率直接提升666%
数字藏品,“赌”字当头
rpn:def concat_box_prediction_layers
“68道 Redis+168道 MySQL”精品面试题(带解析)
Ethernet channel Ethernet channel
娄底污水处理厂实验室建设管理
C# error The 'xmins' attribute is not supported in this context