Comments (5)
请问你的Activity里面做了有关Activity被回收后的状态保存之类的操作了吗?
from alphatabsindicator.
没有,只是重写了onRestoreInstanceState,随便打印了一句话,看看什么情况。后来我在super.onRestoreInstanceState(savedInstanceState); 上面调用alphaTabsIndicator.getTabView(0) 就没问题了,是不是isInit() 初始化的问题?
from alphatabsindicator.
我也遇到这个问题了 看了一下代码
// AlphaTabsIndicator.java
/**
* @return 当View被销毁的时候,保存数据
*/
@Override
protected Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
bundle.putParcelable(STATE_INSTANCE, super.onSaveInstanceState());
bundle.putInt(STATE_ITEM, mCurrentItem);
return bundle;
}
/**
* @param state 用于恢复数据使用
*/
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
mCurrentItem = bundle.getInt(STATE_ITEM);
if (null == mTabViews || mTabViews.isEmpty()) {
super.onRestoreInstanceState(state); // 这里是第199行
return;
}
//重置所有按钮状态
resetState();
//恢复点击的条目颜色
mTabViews.get(mCurrentItem).setIconAlpha(1.0f);
super.onRestoreInstanceState(bundle.getParcelable(STATE_INSTANCE));
} else {
super.onRestoreInstanceState(state);
}
}
// View.java
protected void onRestoreInstanceState(Parcelable state) {
mPrivateFlags |= PFLAG_SAVE_STATE_CALLED;
if (state != null && !(state instanceof AbsSavedState)) {
throw new IllegalArgumentException("Wrong state class, expecting View State but "
+ "received " + state.getClass().toString() + " instead. This usually happens "
+ "when two views of different type have the same id in the same hierarchy. "
+ "This view's id is " + ViewDebug.resolveId(mContext, getId()) + ". Make sure "
+ "other views do not use the same id.");
}
if (state != null && state instanceof BaseSavedState) {
mStartActivityRequestWho = ((BaseSavedState) state).mStartActivityRequestWhoSaved;
}
}
我认为是 View 保存状态根本那就不能使用 Bundle 因为
public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
// ...
}
public static class BaseSavedState extends AbsSavedState {
// ...
}
public abstract class AbsSavedState implements Parcelable {
// ...
}
Bundle 根本就不是 AbsSavedState 或者 BaseSavedState 的子类,所以在 199 行调用 super.onRestoreInstanceState(state); 抛出了异常。
from alphatabsindicator.
谢谢@wangkunlin 提供的信息,由于我的疏忽,确实有类型方面的问题存在,已在新版修改了一个影响此问题的代码,请二位使用1.0.8测试。
from alphatabsindicator.
嗯,客气了。😊
from alphatabsindicator.
Related Issues (20)
- 支持 VectorDrawable 么? HOT 1
- 希望tab能支持跳转activity. HOT 1
- 怎么设置不滑动 HOT 1
- 不绑定viewpager 怎么使用 HOT 1
- 下面的小红点在多次点击滑动后会消失 HOT 1
- 为什么用library可以点击,可以滑动,但是 compile 'com.yinglan.alphatabs:library:1.0.8'就只能点击不能滑动 HOT 5
- 绑定viewpager后, 点击tabview 怎么左右不平滑啊? HOT 2
- 不相邻的滑动,会有颜色错乱问题 HOT 2
- 请问,如何控制角标和icon的水平距离? 右上角的角标和icon的距离 HOT 1
- 如果不设置文字,图标会变的很大,怎么处理
- [Feature requested] Add dividers between items HOT 1
- 如果数字角标可以支持像QQ那样拖拽消除的话,那么这个库就完美了,可以应付绝大部分业务 HOT 1
- 滑动快了 会有闪烁的情况 HOT 1
- 能增加一个下划线吗
- 部分机型出现角标太过小的问题,能否再优化些呢 HOT 4
- 点击发现会把通讯录的角标移除掉,请优化 HOT 1
- 哈哈哈,子尧大神的作品还是不错的哈 HOT 2
- 内存泄漏
- 图片无法按照分辨率缩放
- 能不能通过代码来动态设置显示的文字呢,点击的时候变更文字 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alphatabsindicator.