Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

提个场景不知道这样的改进好不好 #25

Closed
hkq325800 opened this issue Jan 6, 2017 · 1 comment
Closed

提个场景不知道这样的改进好不好 #25

hkq325800 opened this issue Jan 6, 2017 · 1 comment

Comments

@hkq325800
Copy link

fragment中含list使用superAdapter 发起请求迅速finish activity会报"getSystemService"on a null object reference明显是context为空了导致LayoutInflater.from(context)的crash

改进方法:在LayoutInflater.from(context)前判空 否则的话我现在都是在new xxAdapter前判空 还挺麻烦的

@chenenyu
Copy link
Collaborator

chenenyu commented Jan 6, 2017

LayoutInflater.from(context)是必须要提供一个非null的context的,否则的话没有Inflater就不能正常工作了,如果你是getActivity()返回null,建议自己处理下这种问题,比如http://stackoverflow.com/questions/11631408/android-fragment-getactivity-sometime-returns-null

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

No branches or pull requests

2 participants