首先给两个截图看一下 基本框架,java和xml文件

每一个java对应一个Fragment,每一个Fragment对应一个xml文件

主要内容:


如何定制RadioButton:

设置radiobutton的android:button="@null";

设置radiobutton的android:background为一个自定义selector

设置alignparentbottom=true;



废话不多说了,上
.-' _..`.
/ .'_.'.'
| .' (.)`.
;' ,_ `.
.--.__________.' ; `.;-'
| ./ /
| | /
`..'`-._ _____, ..'
/ | | | |\ \
/ /| | | | \ \
/ / | | | | \ \
/_/ |_| |_| \_\
|__\ |__\ |__\ |__\

ZhuActivity java代码

package net.xiaocool.yunzhu.activity;
/**
* Created by Administrator on 2015/6/11.
*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Window;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import net.xiaocool.yunzhu.R;
public class ZhuActivity extends FragmentActivity {
private Fragment[] mFragments;
private RadioGroup bottomRg;
private FragmentManager fragmentManager;
private FragmentTransaction fragmentTransaction;
private RadioButton rbone, rbTwo, three, rbFour;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.textradiobutton);
mFragments = new Fragment[4];
fragmentManager = getSupportFragmentManager();
mFragments[0] = fragmentManager.findFragmentById(R.id.fragement_dingdan);
mFragments[1] = fragmentManager.findFragmentById(R.id.fragement_dingdan);
mFragments[2] = fragmentManager.findFragmentById(R.id.fragement_chat);
mFragments[3] = fragmentManager.findFragmentById(R.id.fragement_chaper);
fragmentTransaction = fragmentManager.beginTransaction()
.hide(mFragments[0]).hide(mFragments[1]).hide(mFragments[2]).hide(mFragments[3]);
fragmentTransaction.show(mFragments[0]).commit();
setFragmentIndicator();
}

private void setFragmentIndicator() {
bottomRg = (RadioGroup) findViewById(R.id.group);
rbone = (RadioButton) findViewById(R.id.one);
rbTwo = (RadioButton) findViewById(R.id.two);
three = (RadioButton) findViewById(R.id.three);
rbFour = (RadioButton) findViewById(R.id.four);
bottomRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
fragmentTransaction = fragmentManager.beginTransaction()
.hide(mFragments[0]).hide(mFragments[1])
.hide(mFragments[2]
).hide(mFragments[3]);
switch (checkedId) {
case R.id.one:
fragmentTransaction.show(mFragments[0]).commit();
break;
case R.id.two:
fragmentTransaction.show(mFragments[1]).commit();
break;
case R.id.three:
fragmentTransaction.show(mFragments[2]).commit();
break;
case R.id.four:
fragmentTransaction.show(mFragments[3]).commit();
break;
default:
break;
}
}
});
}
}





对应的xml文件


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="#0061BB"
>
<ImageView
android:id="@+id/me"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:src="@drawable/ic_login_phone"
android:layout_gravity="center_vertical"
/>
<TextView

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#EAF2FA"
android:text="云助养车"
android:textSize="30sp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="60dp"/>
</LinearLayout>-->
<fragment
android:id="@+id/fragment_diandian"
android:name="net.xiaocool.yunzhu.activity.Frag"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />

<fragment
android:id="@+id/fragement_dingdan"
android:name="net.xiaocool.yunzhu.activity.Frag2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />

<fragment
android:name="net.xiaocool.yunzhu.activity.Frag3"
android:id="@+id/fragement_chat"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />
<fragment
android:id="@+id/fragement_chaper"
android:name="net.xiaocool.yunzhu.activity.Frag4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />

<RadioGroup
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/one"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/change"
style=""
android:background="@drawable/bg_button_down"

android:button="@null"
android:padding="10dip"
android:text="Wechat"
android:textSize="20sp" />
<RadioButton
android:id="@+id/two"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_button_down"
android:button="@null"
android:padding="10dip"
android:text="Content"
android:textSize="20sp" />
<RadioButton
android:id="@+id/three"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_button_down"
android:button="@null"
android:padding="10dip"
android:text="Find"
android:textSize="20sp"
/>
<RadioButton
android:id="@+id/four"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_button_down"
android:button="@null"
android:padding="10dip"
android:text="Me"
android:textSize="20sp" />
</RadioGroup>
<!--<android.support.v4.view.ViewPager
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/group"
android:layout_alignParentTop="true" />-->
</RelativeLayout>




四个Frag

package net.xiaocool.yunzhu.activity;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.xiaocool.yunzhu.R;

/**
* Created by Administrator on 2015/6/11.
*/
public class Frag extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.frag1, container, false);
}
}

对应的xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="#0061BB"
>


<TextView
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#EAF2FA"
android:text="订单"
android:textSize="30sp"

/>
</LinearLayout>


<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="这是订单"
android:textColor="#000000" />

</LinearLayout>










































更多相关文章

  1. Android-NDK开发之基础--Android(安卓)NDK开发技巧二
  2. Android(安卓)软件盘不自动弹出解决办
  3. android开发之播放资源文件中的视频
  4. [Android]【安卓】RecyclerView Items间隔设置
  5. 2. Android(安卓)Build系统
  6. Android之创建自定义属性
  7. LinearLayout 中的分割线
  8. android启动过程配置文件的解析与语法 .
  9. android 存储文件到sdcard下

随机推荐

  1. 一步步教你用Android(安卓)Google Map
  2. GDB + gdbserver 远程调试android native
  3. 在Ubuntu上下载、编译和安装Android最新
  4. android中Content Provider
  5. Android(安卓)LinearLayout的布局属性介
  6. android
  7. android 获取路径目录方法以及判断目录是
  8. android 数字键盘使用
  9. android中从图库中选取图片
  10. 原始Android的目标机代码结构