-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onCreateView返回0时setCallBack出错 #139
Comments
@Pacey6 你好,可能注册时机不对,请参照Demo |
@KingJA 测试发现, 必须先执行showCallback, 再执行setCallback才不会报"onCreateView中返回0"的异常 |
因为不执行show的, HintCallback的View不会添加上去, 此时的rootView为null, 默认会走inflate通过onCreateView获取布局id进行填充, 但是HintCallback不是通过布局生成View, 而是通过代码创建的View, 所以一定会报报"onCreateView中返回0"的异常 |
感觉可以和getRootView一样 public View getRootView() {
int resId = onCreateView();
if (resId == 0 && rootView != null) {
return rootView;
}
if (onBuildView(context) != null) {
rootView = onBuildView(context);
}
if (rootView == null) {
rootView = View.inflate(context, onCreateView(), null);
}
rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onReloadEvent(context, rootView)) {
return;
}
if (onReloadListener != null) {
onReloadListener.onReload(v);
}
}
});
onViewCreate(context, rootView);
return rootView;
} |
我也碰见了,作者这是不维护了咩
把这个方法改到rootView那去,这样就不用必须指定onCreateView的id了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
若仿照自带HintCallback那样在onCreateView中返回0,则:
loadService.setCallBack(HintCallback.class, (context, view1) -> {});
报错找不到资源0x00
The text was updated successfully, but these errors were encountered: