Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
1.05 Create ArrayAdapter to eventually use to populate the ListView
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyla committed Mar 4, 2015
1 parent de032c1 commit 0281f77
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import android.widget.ArrayAdapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;



public class MainActivity extends ActionBarActivity {

@Override
Expand Down Expand Up @@ -70,6 +68,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
*/
public static class PlaceholderFragment extends Fragment {

ArrayAdapter<String> mForecastAdapter;

public PlaceholderFragment() {
}

Expand All @@ -88,6 +88,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
"Sun 6/29 - Sunny - 20/7"
};
List<String> weekForecast = new ArrayList<String>(Arrays.asList(data));


// Now that we have some dummy forecast data, create an ArrayAdapter.
// The ArrayAdapter will take data from a source (like our dummy forecast) and
// use it to populate the ListView it's attached to.
mForecastAdapter =
new ArrayAdapter<String>(
getActivity(), // The current context (this activity)
R.layout.list_item_forecast, // The name of the layout ID.
R.id.list_item_forecast_textview, // The ID of the textview to populate.
weekForecast);

View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
Expand Down

0 comments on commit 0281f77

Please sign in to comment.