本文介绍了onCreate()中的空指针异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面提到的代码中我得到空指针异常。需要做什么?
In the below mentioned code I am getting null pointer exception. What need to be done?
private static final String PREFERENCES = "PREFERENCES";
private static final String URL = "url";
private String lastUrl;
private EditText urlText;
private TextView textView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
urlText = (EditText) findViewById(R.id.address);
textView = (TextView) findViewById(R.id.pagetext);
loadPreferences();
urlText.setText(lastUrl);
}
推荐答案
这篇关于onCreate()中的空指针异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!