Skip to content

Instantly share code, notes, and snippets.

@naanT
Last active August 29, 2015 14:27
Show Gist options
  • Save naanT/2ec4a7ce315d7c0090d6 to your computer and use it in GitHub Desktop.
Save naanT/2ec4a7ce315d7c0090d6 to your computer and use it in GitHub Desktop.
ArrayAdapter populating ListView
ListView forecastListView;
View view = inflater.inflate(R.layout.fragment_main, container, false);
String[] forecastData = {"Sunny", "Cloudy", "Warm", "Hot", "Cold"};
List<String> forecastList = new ArrayList<String>(Arrays.asList(forecastData));
forecastAdapter = new ArrayAdapter<String>(getActivity().getBaseContext(),
R.layout.list_item_forecast, R.id.list_item_forecast_textView, forecastList);
forecastListView = (ListView) view.findViewById(R.id.listView_forecast);
forecastListView.setAdapter(forecastAdapter);
return view;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment