//BottomTabBar实现底部选项卡
2017-10-26 10:30
274 查看
//依赖
compile 'com.hjm:BottomTabBar:1.1.1'
//布局文件
<com.hjm.bottomtabbar.BottomTabBar
android:id="@+id/btb"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</com.hjm.bottomtabbar.BottomTabBar>
public class MyActivty_Main extends AppCompatActivity {
private BottomTabBar bottomTabBar;
private List<Fragment> list;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_activty__main);
bottomTabBar= (BottomTabBar) findViewById(R.id.btb);
list=new ArrayList<>();
list.add(new Fragment_a());
list.add(new Fragment_b());
list.add(new Fragment_c());
bottomTabBar.init(getSupportFragmentManager())
.setImgSize(90, 90)
.setFontSize(1)
.setTabPadding(4, 6, 10)
.setChangeColor(Color.GREEN, Color.RED)
.addTabItem(" ", R.mipmap.index_checked, R.mipmap.index_unchecked, Fragment_a.class)
.addTabItem(" ", R.mipmap.recommand_checked, R.mipmap.recommand_unchecked, Fragment_b.class)
.addTabItem(" ", R.mipmap.mine_checked, R.mipmap.mine_unchecked,Fragment_c.class)
.isShowDivider(false)
.setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {
@Override
public void onTabChange(int position, String name) {
Log.i("TGA", "位置:" + position + " 选项卡:" + name);
sp = MyUtil.getSharedPreferencesInstance(MyActivty_Main.this);
if (position==2){
boolean auto = sp.getBoolean("check", false);
if (auto==false){
Intent intent=new Intent(MyActivty_Main.this,MainActivity_Login.class);
startActivity(intent);
}
}
}
});
}
}
compile 'com.hjm:BottomTabBar:1.1.1'
//布局文件
<com.hjm.bottomtabbar.BottomTabBar
android:id="@+id/btb"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</com.hjm.bottomtabbar.BottomTabBar>
public class MyActivty_Main extends AppCompatActivity {
private BottomTabBar bottomTabBar;
private List<Fragment> list;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_activty__main);
bottomTabBar= (BottomTabBar) findViewById(R.id.btb);
list=new ArrayList<>();
list.add(new Fragment_a());
list.add(new Fragment_b());
list.add(new Fragment_c());
bottomTabBar.init(getSupportFragmentManager())
.setImgSize(90, 90)
.setFontSize(1)
.setTabPadding(4, 6, 10)
.setChangeColor(Color.GREEN, Color.RED)
.addTabItem(" ", R.mipmap.index_checked, R.mipmap.index_unchecked, Fragment_a.class)
.addTabItem(" ", R.mipmap.recommand_checked, R.mipmap.recommand_unchecked, Fragment_b.class)
.addTabItem(" ", R.mipmap.mine_checked, R.mipmap.mine_unchecked,Fragment_c.class)
.isShowDivider(false)
.setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {
@Override
public void onTabChange(int position, String name) {
Log.i("TGA", "位置:" + position + " 选项卡:" + name);
sp = MyUtil.getSharedPreferencesInstance(MyActivty_Main.this);
if (position==2){
boolean auto = sp.getBoolean("check", false);
if (auto==false){
Intent intent=new Intent(MyActivty_Main.this,MainActivity_Login.class);
startActivity(intent);
}
}
}
});
}
}
相关文章推荐
- BottomTabBar实现项目底部导航栏(自带选中变色)
- BottomTabBar实现底部导航页
- FragmentTabHostBottomDemo【FragmentTabHost + Fragment实现底部选项卡】
- TabLayoutBottomDemo【TabLayout实现底部选项卡】
- 使用BottomTabBar+Fragment实现底部导航页
- Android利用BottomNavigationView和ViewPager实现底部导航及源码下载分享
- 一个带动画的页面底部的TabBar的实现
- vue自定义底部导航栏Tabbar的实现代码
- Android 底部导航栏 多种实现方法,目前自定义的BottomNavigationBar比较不错
- 页面布局之使用TabActivity实现底部Tabbar
- Android仿微信底部实现Tab选项卡切换效果
- BottomTabBar的底部栏
- BottomTabBar添加底部布局视图
- 微信小程序开发之选项卡(窗口底部TabBar)页面切换
- Android学习之BottomNavigationBar实现Android特色底部导航栏
- 仿御泥坊 完美实现电商类项目底部选项卡切换Fragment页面
- 使用选项卡TabWidget与TabHost实现底部或者顶部四个分类按钮 点击切换对应的fragment
- Android仿微信底部实现Tab选项卡切换效果
- BottomNavigationView实现底部导航栏的实现(一)
- android底部选项卡(二)FragmentTabHost +Fragment 实现