I have a ArrayAdapter
declaration. I want to clear it and add some other data.
So how can I change it to global?
public class ForecastFragment extends Fragment {
private ArrayAdapter<String> mForecastArray;
// ...
List<String> weekForecast = new ArrayList<String>(Arrays.asList(forecastArray));
mForecastArray = new ArrayAdapter<String>(getActivity(), R.layout.list_item_forecast, R.id.list_item_forecast_textview, weekForecast);
ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
listView.setAdapter(mForecastArray);
}
Another class
public class FetchWeatherTask extends AsyncTask<String, Void, String[]>{
protected void onPostExecute(String[] strings) {
if (strings!=null){
mForecastArray.clear();
for (String dayForecast : strings){
mForecastArray.add(dayForecast);
}
}
}
I couldn't use mForecastArray
in the second class