四个Fragment相互切换界面,底部几个TextView点击切换相互切换界面

fm_touTiao = new Fragment_TouTiao();
fm_guoNei = new Fragment_GuoNei();
fm_junShi = new Fragment_JunShi();
fm_keJi = new Fragment_KeJi();


TextView toutiao = (TextView) findViewById(R.id.btnTouTiao);
TextView guonei = (TextView) findViewById(R.id.btnGuoNei);
TextView junshi = (TextView) findViewById(R.id.btnJunShi);
TextView keji = (TextView) findViewById(R.id.btnKeJi);
getSupportFragmentManager().beginTransaction()
        .add(R.id.framelayout, fm_touTiao)
        .add(R.id.framelayout, fm_guoNei)
        .add(R.id.framelayout, fm_junShi)
        .add(R.id.framelayout, fm_keJi)
        .hide(fm_guoNei)
        .hide(fm_junShi)
        .hide(fm_keJi)
        .commit();

toutiao.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        getSupportFragmentManager().beginTransaction()
                .show(fm_touTiao)
                .hide(fm_guoNei)
                .hide(fm_junShi)
                .hide(fm_keJi)
                .commit();
    }

});

这里只举一个例子,剩下都一样

你可能感兴趣的:(四个Fragment相互切换界面,底部几个TextView点击切换相互切换界面)