我们有很多页面 主页面下面会有导航栏
import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.view.Window; import android.view.WindowManager; import android.widget.RadioButton; import android.widget.RadioGroup; import com.example.xue.shoppingyuan.MainActivity; import com.example.xue.shoppingyuan.R; import java.util.ArrayList; public class Homepage extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener { private RadioGroup rg; private RadioButton[] rbArray; private ArrayList<Fragment> listFragment; private FragmentManager fm; private int count = 0; private RadioButton rb_1,rb_2,rb_3,rb_4,rb_5; private static Homepage homepage = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //隐藏标题栏 supportRequestWindowFeature(Window.FEATURE_NO_TITLE); //隐藏状态栏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_homepage2); homepage = this; rb_1 = (RadioButton) findViewById(R.id.rb_btn_1); rb_2 = (RadioButton) findViewById(R.id.rb_btn_2); rb_3 = (RadioButton) findViewById(R.id.rb_btn_3); rb_4 = (RadioButton) findViewById(R.id.rb_btn_4); rb_5 = (RadioButton) findViewById(R.id.rb_btn_5); initView(); } /** * 判断下面导航栏是否为点击状态,如果不是点击的时候就实现换图,如果是就不变 * @param id */ private void showFragment(int id) { FragmentTransaction tt = fm