类似RadriodButtom(Fragment切换)的菜单选择器

https://blog.csdn.net/leehbhs/article/details/76572325


Activity代码

import android.graphics.Color;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.support.v7.app.AppCompatActivity;

import com.example.tonghang.fragment.AFragment;

import com.example.tonghang.fragment.BFragment;

import com.example.tonghang.fragment.CFragment;

import com.example.tonghang.fragment.DFragment;

import com.hjm.bottomtabbar.BottomTabBar;

import java.util.ArrayList;

public class LoginActivityextends AppCompatActivity{

private AFragmentaFragment;

private BFragmentbFragment;

private CFragmentcFragment;

private DFragmentdFragment;

private ArrayListlist =new ArrayList<>();

private ArrayListlists =new ArrayList<>();

private BottomTabBarbom;

@Override

    protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login2);

initView();

initData();

}

private void initView() {

bom = (BottomTabBar) findViewById(R.id.bottom_tab_bar);

}

private void initData() {

bom.init(getSupportFragmentManager())

.setImgSize(80,80)

.setFontSize(15)

.setTabPadding(4,6,10)

.setChangeColor(Color.RED,Color.DKGRAY)

.addTabItem("咨询",R.drawable.zixun6,AFragment.class)

//绑定布局,XML文件

.addTabItem("话题",R.drawable.huati6,BFragment.class)

.addTabItem("圈子",R.drawable.quanzi6,CFragment.class)

.addTabItem("我的",R.drawable.wode6,DFragment.class)

.isShowDivider(false)

.setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {

@Override

                    public void onTabChange(int position, String name) {

}

});

}

}

XML布局,

首选是选中为true,未选中为false。其后相反,选中为false,未选中为true

你可能感兴趣的:(类似RadriodButtom(Fragment切换)的菜单选择器)