我遇到异常:
java.lang.IllegalStateException: System services not available to Activities before onCreate()
在 onResume() 中重新初始化 layoutInflater 时:
layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
我正在尝试更新 view flipper 的内容。 任何人都可以建议我对此进行更正以解决异常。
最佳答案
看:
public class MyActivity extends Activity {
// LayoutInflater inflater = (LayoutInflater) context
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // NOT CORRECT
LayoutInflater inflater; // correct
@Override
protected void onCreate(Bundle saved) {
super.onCreate(saved);
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // correct
}
}
关于android - java.lang.IllegalStateException : System services not available to Activities before onCreate() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23441694/