<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.zhoukao1.MainActivity">
<FrameLayout
android:id="@+id/framelayout"
android:layout_weight="9"
android:layout_width="match_parent"
android:layout_height="0dp"></FrameLayout>
<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_height="0dp">
<RadioButton
android:id="@+id/rb1"
android:layout_width="0dp"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:text="新品"
android:layout_height="match_parent" />
<RadioButton
android:id="@+id/rb2"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:button="@null"
android:text="精选"
android:layout_height="match_parent" />
<RadioButton
android:id="@+id/rb3"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:button="@null"
android:text="分类"
android:layout_height="match_parent" />
<RadioButton
android:id="@+id/rb4"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:button="@null"
android:text="我的衣橱"
android:layout_height="match_parent" />
<RadioButton
android:id="@+id/rb5"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:button="@null"
android:text="个人中心"
android:layout_height="match_parent" />
</RadioGroup>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
@BindView(R.id.framelayout)
FrameLayout framelayout;
@BindView(R.id.rb1)
RadioButton rb1;
@BindView(R.id.rb2)
RadioButton rb2;
@BindView(R.id.rb3)
RadioButton rb3;
@BindView(R.id.rb4)
RadioButton rb4;
@BindView(R.id.rb5)
RadioButton rb5;
@BindView(R.id.rg)
RadioGroup rg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra1()).commit();
}
@OnClick({R.id.rb1, R.id.rb2, R.id.rb3, R.id.rb4, R.id.rb5})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.rb1:
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra1()).commit();
break;
case R.id.rb2:
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra2()).commit();
break;
case R.id.rb3:
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra3()).commit();
break;
case R.id.rb4:
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra4()).commit();
break;
case R.id.rb5:
getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,new fra5()).commit();
break;
}
}
}