Fragment与RadioGroup简单运用
来源:互联网 发布:装饰装修设计软件 编辑:程序博客网 时间:2024/06/09 19:29
//主页面布局
<FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="9" android:id="@+id/frag"></FrameLayout><RadioGroup android:id="@+id/rg" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal"> <RadioButton android:id="@+id/btn1" android:layout_width="0dp" android:layout_weight="1" android:button="@null" android:text="首页" android:gravity="center" android:layout_height="match_parent" /> <RadioButton android:id="@+id/btn2" android:layout_width="0dp" android:layout_weight="1" android:button="@null" android:text="发现" android:gravity="center" android:layout_height="match_parent" /> <RadioButton android:id="@+id/btn3" android:layout_width="0dp" android:text="下载" android:gravity="center" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" /> <RadioButton android:id="@+id/btn4" android:layout_width="0dp" android:layout_weight="1" android:text="我的" android:gravity="center" android:button="@null" android:layout_height="match_parent" /></RadioGroup>
//MainActivity类
public class MainActivity extends AppCompatActivity { private RadioGroup rg; private FrameLayout frag; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
//找到控件 rg = (RadioGroup) findViewById(R.id.rg); frag = (FrameLayout) findViewById(R.id.frag);
addFragment(new Fragment01());
//RadioGroup的点击事件 rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId){ case R.id.btn1: addFragment(new Fragment01()); break; case R.id.btn2: addFragment(new Fragment02()); break; case R.id.btn3: addFragment(new Fragment03()); break; case R.id.btn4: addFragment(new Fragment04()); break; } } }); } public void addFragment(Fragment f){ FragmentManager manager=getSupportFragmentManager(); FragmentTransaction fragmentTransaction = manager.beginTransaction(); fragmentTransaction.replace(R.id.frag,f); fragmentTransaction.commit(); }}
阅读全文
0 0
- Fragment与RadioGroup简单运用
- RadioGroup与Fragment使用
- APP导航Fragment与RadioGroup
- RadioGroup+Fragment 实现简单选项卡切换
- RadioGroup+Fragment
- radioGroup+fragment
- 实现RadioGroup与Fragment的交互
- Fragment+ViewPager+RadioGroup实现的页面简单切换
- Fragment+RadioGroup来搭建一下简单的页面架构
- 简单快速实现导航条(Viewpager+Fragment+Radiogroup)
- RadioGroup与Radiobutton对fragment进行滑动、点击监听
- Fragment+RadioGroup点击切换Fragment
- Fragment + TabHost + RadioGroup
- ViewPage + RadioGroup + Fragment学习
- RadioGroup+ViewPager+Fragment
- Radiogroup+radioButton+fragment
- RadioGroup+Fragment的替换
- 点击RadioGroup切换Fragment
- sourcetree 使用submodule同步公共库适用于组件化开发和公共开发
- ecplise使用jetty启动maven项目java.lang.ClassNotFoundException
- VUE开发SPA之较舒服的微信授权登录
- scala学习笔记-类
- Java数据类型
- Fragment与RadioGroup简单运用
- react-native 10打包apk
- 卸载rpm包
- 关闭node进程
- opencv中使用中点画圆算法
- 机器学习第4章第2节 : R语言科学计算
- 为什么我们需要看技术公众号文章?
- iOS开发中OC调用C++文件
- VideoCapture类