提交 883ed4d9 编写于 作者: C ccw

更新README

上级 b771cd1e
......@@ -339,15 +339,20 @@ drawable的编写如下:
只需为BottomBarLayout设置页签选中的监听,在回调中进行以下处理:
mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() {
mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() {
@Override
public void onItemSelected(final BottomBarItem bottomBarItem, int position) {
if (position == 0){
public void onItemSelected(final BottomBarItem bottomBarItem, int previousPosition, final int currentPosition) {
Log.i("MainActivity", "position: " + currentPosition);
if (currentPosition == 0) {
//如果是第一个,即首页
if (mBottomBarLayout.getCurrentItem() == position){
if (previousPosition == currentPosition) {
//如果是在原来位置上点击,更换首页图标并播放旋转动画
bottomBarItem.setIconSelectedResourceId(R.mipmap.tab_loading);//更换成加载图标
bottomBarItem.setStatus(true);
if (mRotateAnimation != null && !mRotateAnimation.hasEnded()){
//如果当前动画正在执行
return;
}
bottomBarItem.setSelectedIcon(R.mipmap.tab_loading);//更换成加载图标
//播放旋转动画
if (mRotateAnimation == null) {
......@@ -365,18 +370,18 @@ drawable的编写如下:
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
bottomBarItem.setIconSelectedResourceId(R.mipmap.tab_home_selected);//更换成首页原来图标
bottomBarItem.setStatus(true);//刷新图标
boolean tabNotChanged = mBottomBarLayout.getCurrentItem() == currentPosition; //是否还停留在当前页签
bottomBarItem.setSelectedIcon(R.mipmap.tab_home_selected);//更换成首页原来选中图标
cancelTabLoading(bottomBarItem);
}
},3000);
}, 3000);
return;
}
}
//如果点击了其他条目
BottomBarItem bottomItem = mBottomBarLayout.getBottomItem(0);
bottomItem.setIconSelectedResourceId(R.mipmap.tab_home_selected);//更换为原来的图标
bottomItem.setSelectedIcon(R.mipmap.tab_home_selected);//更换为原来的图标
cancelTabLoading(bottomItem);//停止旋转动画
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册