首先給兩個(gè)截圖看一下 基本框架,java和xml文件
成都創(chuàng)新互聯(lián)是一家業(yè)務(wù)范圍包括IDC托管業(yè)務(wù),網(wǎng)絡(luò)空間、主機(jī)租用、主機(jī)托管,四川、重慶、廣東電信服務(wù)器租用,IDC機(jī)房托管,成都網(wǎng)通服務(wù)器托管,成都服務(wù)器租用,業(yè)務(wù)范圍遍及中國大陸、港澳臺(tái)以及歐美等多個(gè)國家及地區(qū)的互聯(lián)網(wǎng)數(shù)據(jù)服務(wù)公司。
每一個(gè)java對(duì)應(yīng)一個(gè)Fragment,每一個(gè)Fragment對(duì)應(yīng)一個(gè)xml文件
主要內(nèi)容:
如何定制RadioButton:
設(shè)置radiobutton的android:button="@null";
設(shè)置radiobutton的android:background為一個(gè)自定義selector
設(shè)置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;
}
}
});
}
}
對(duì)應(yīng)的xml文件
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
android:name="net.xiaocool.yunzhu.activity.Frag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />
android:name="net.xiaocool.yunzhu.activity.Frag2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />
android:id="@+id/fragement_chat"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />
android:name="net.xiaocool.yunzhu.activity.Frag4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
android:layout_width="96dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/change"
android:background="@drawable/bg_button_down"
android:button="@null"
android:padding="10dip"
android:text="Wechat"
android:textSize="20sp" />
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" />
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"
/>
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" />
四個(gè)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);
}
}
對(duì)應(yīng)的xml文件
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_height="60dp"
android:orientation="horizontal"
android:background="#0061BB"
>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#EAF2FA"
android:text="訂單"
android:textSize="30sp"
/>
android:layout_height="fill_parent"
android:gravity="center"
android:text="這是訂單"
android:textColor="#000000" />