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

更新README

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