Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save taywils/5633177 to your computer and use it in GitHub Desktop.
Save taywils/5633177 to your computer and use it in GitHub Desktop.
PlaceAdapter... adapters are such mindf#$%s
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