Created
May 23, 2013 06:56
-
-
Save taywils/5633177 to your computer and use it in GitHub Desktop.
PlaceAdapter... adapters are such mindf#$%s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class PlaceAdapter extends ArrayAdapter<Place> { | |
public Context context; | |
public int layoutResourceId; | |
public ArrayList<Place> places; | |
public PlaceAdapter(Context context, int layoutResourceId, ArrayList<Place> places) { | |
super(context, layoutResourceId, places); | |
this.layoutResourceId = layoutResourceId; | |
this.places = places; | |
} | |
@Override | |
public View getView(int rowIndex, View convertView, ViewGroup parent) { | |
View row = convertView; | |
if(null == row) { | |
LayoutInflater layout = (LayoutInflater)getSystemService( | |
Context.LAYOUT_INFLATER_SERVICE | |
); | |
row = layout.inflate(R.layout.httptestrow, null); | |
} | |
Place place = places.get(rowIndex); | |
if(null != place) { | |
TextView name = (TextView) row.findViewById(R.id.htttptestrow_name); | |
TextView vicinity = (TextView) row.findViewById( | |
R.id.httptestrow_vicinity); | |
if(null != name) { | |
name.setText(place.getName()); | |
} | |
if(null != vicinity) { | |
vicinity.setText(place.getVicinity()); | |
} | |
} | |
return row; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment