Advertisement
Guest User

NullPointerException

a guest
Mar 7th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. protected List<WeatherForecastInfo.ListItem.Weather> list = null;
  2. protected ArrayAdapter<WeatherForecastInfo.ListItem.Weather> adapter = null;
  3.  
  4. //and in onCreate I have
  5.  
  6. mapUtil = WeatherUtil.newInstance();
  7.         button.setOnClickListener(new OnClickListener() {
  8.  
  9.             @Override
  10.             public void onClick(View v) {
  11.                 // TODO Auto-generated method stub
  12.                 new AsyncTask<String, Void, WeatherForecastInfo>() {
  13.                     @Override
  14.                     protected void onPreExecute() {
  15.                         progressDialog = new ProgressDialog(DemoActivity.this);
  16.                         progressDialog.setTitle("Wait...");
  17.                         progressDialog.setMessage("Data is being loaded...");
  18.                         progressDialog.show();
  19.                     }
  20.  
  21.                     @Override
  22.                     protected WeatherForecastInfo doInBackground(
  23.                             String... params) {
  24.  
  25.                         return mapUtil.getForecastByCityName(DemoActivity.this, editText.getText().toString(), 2);
  26.                     }
  27.                     @Override
  28.                     protected void onPostExecute(WeatherForecastInfo result) {
  29.  
  30.                         textView.setText(result.getCity().getName()+ " " + result.getCity().getCountry());
  31.                         list = result.getListItem().getWeather(); // Here Im getting NPE why???
  32.                         adapter = new ArrayAdapter<WeatherForecastInfo.ListItem.Weather>(DemoActivity.this, android.R.layout.simple_list_item_1, list);
  33.                         listView.setAdapter(adapter);
  34.                         progressDialog.dismiss();
  35.                     }
  36.                 }.execute(null, null, null);
  37.  
  38.             }
  39.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement