抽屉布局加上RadioGroup+点击进行切换
来源:互联网 发布:北京知象科技怎么样 编辑:程序博客网 时间:2024/06/07 20:56
抽屉布局加上RadioGroup
?xml version=”1.0” encoding=”utf-8”?>
android.support.v4.widget.DrawerLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:id=”@+id/drawer_layout”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<RelativeLayout android:id="@+id/relative" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fragment_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"></FrameLayout> <RadioGroup android:layout_alignParentBottom="true" android:id="@+id/radio_group" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="50dp"> <RadioButton android:id="@+id/bt02" android:button="@null" android:gravity="center" android:padding="5dp" android:background="@drawable/radio_selector" android:checked="true" android:layout_width="0dp" android:layout_height="match_parent" android:text="首页" android:layout_weight="1"/> <RadioButton android:id="@+id/bt03" android:button="@null" android:gravity="center" android:padding="5dp" android:background="@drawable/radio_selector" android:layout_width="0dp" android:layout_height="match_parent" android:text="联系人" android:layout_weight="1"/> <RadioButton android:id="@+id/bt04" android:button="@null" android:gravity="center" android:padding="5dp" android:background="@drawable/radio_selector" android:layout_width="0dp" android:layout_height="match_parent" android:text="视频" android:layout_weight="1"/> <RadioButton android:id="@+id/bt01" android:button="@null" android:gravity="center" android:padding="5dp" android:background="@drawable/radio_selector" android:layout_width="0dp" android:layout_height="match_parent" android:text="我的" android:layout_weight="1"/> </RadioGroup></RelativeLayout><!-- 抽屉布局--><LinearLayout android:background="#ffffff" android:id="@+id/liner_drawer" android:layout_gravity="left" android:layout_width="300dp" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:src="@mipmap/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="你好" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="未登录" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout></LinearLayout>
Activity
package com.example.day02_0927;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
public class MainActivity extends AppCompatActivity {
private DrawerLayout drawerlayout;private RadioGroup radiogroup;private LinearLayout linearLayout;@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout); radiogroup = (RadioGroup) findViewById(R.id.radio_group); linearLayout = (LinearLayout) findViewById(R.id.liner_drawer); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout,new FragmentNews()).commit(); radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId){ case R.id.bt01: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout,new FragmentNews()).commit(); break; case R.id.bt02: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout,new FragmentNews()).commit(); break; case R.id.bt03: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout,new FragmentNews()).commit(); break; case R.id.bt04: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout,new FragmentNews()).commit(); break; } } });}
}
阅读全文
0 0
- 抽屉布局加上RadioGroup+点击进行切换
- 点击RadioGroup切换Fragment
- 点击RadioGroup切换图片
- RadioGroup 点击切换背景图片
- RadioGroup点击RadioButtion切换Fragment
- Fragment+RadioGroup点击切换Fragment
- RadioGroup和Fragment相结合实现点击RadioButton进行Fragment的切换
- RecyclerView+ButterKnife点击按钮进行布局切换与添加删除
- 159.n1-点击RadioGroup切换ViewPager
- FrameLayout加RadioGroup实现底部点击切换
- RadioGroup中点击切换RadioButton背景
- RecyclerView点击切换布局
- RecyclerView点击切换布局
- RecycleView点击切换布局
- 给点击的布局加上背景
- RecyclerView-点击切换多种布局
- [Android学习笔记]fragment配合RadioGroup实现点击切换内容
- RadioGroup+Fragment实现点击切换,类似美团有Demo
- tensorflow学习笔记----二(CIFAR-10 模型 )
- ES6入门(三):数据类型
- git和VCS的一些常用指令、使用心得和疑问
- 顺序表应用4-2:元素位置互换之逆置算法(数据改进)
- nodejs 文件-fs
- 抽屉布局加上RadioGroup+点击进行切换
- OpenCV图像读取与操作
- 【数据库】作业二
- 设计模式-组合模式
- Median of Two Sorted Arrays
- Web前端工程师要掌握的基础知识和技能
- 【LeetCode算法练习(C++)】Letter Combinations of a Phone Number
- linux驱动学习记录(二)-PCI驱动框架
- Java History 001 概论