我是Android新手。请给我一些帮助。提前致谢! 以下代码是第二个活动
的一部分public class getInfoActivity extends AppCompatActivity{
public TextView textViewCityName;
public TextView textViewTemp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewCityName = (TextView) findViewById(R.id.textViewCityName);
textViewTemp = (TextView) findViewById(R.id.textViewTemp);
...
然后 AsyncTask onPostExecute 代码:
protected void onPostExecute(Double aDouble) {
//textViewCityName.setText("2172729"); //crashed the APP
Toast.makeText(getInfoActivity.this, "2172729",
Toast.LENGTH_SHORT).show(); //working
}
错误信息
FATAL EXCEPTION: main
java.lang.NullPointerException
非常感谢你!
答案 0 :(得分:0)
好的,请使用此textViewCityName.get().setText("2172729");