Skip to content
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

查找tag为null,startFragment报错 #80

Open
CaiJinFu opened this issue Jul 26, 2019 · 1 comment
Open

查找tag为null,startFragment报错 #80

CaiJinFu opened this issue Jul 26, 2019 · 1 comment

Comments

@CaiJinFu
Copy link

添加tag
Fragment fragment = LoginSelectIdentityFragment.newInstance(); Rigger.getRigger(fragment).setFragmentTag(LoginSelectIdentityFragment.class.getName()); Rigger.getRigger(puppet).startFragment(fragment);
查找tag
Fragment fragment = Rigger.getRigger(this) .findFragmentByTag(LoginSelectIdentityFragment.class.getName());
这时查找的fragment总是为null,然后我又Rigger.getRigger(puppet).startFragment(LoginSelectIdentityFragment),结果就报错了。这是为什么啊?

@JingYeoh
Copy link
Owner

JingYeoh commented Aug 2, 2019

不建议保存 Fragment 对象,使用 Rigger,你只需要保存 Fragment tag 即可。

LoginSelectIdentityFragment fragment = LoginSelectIdentityFragment.newInstance(); 
String loginSelectIdentityTag = Rigger.getRigger(fragment).getFragmentTag();

之后你需要的时候通过 tag 去进行操作 Fragment.

Rigger.getRigger(this).findFragmentByTag(loginSelectIdentityTag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants