Back to project page myAndroidApps.
The source code is released under:
This is my first GitHub try. Be gentle :)
If you think the Android project myAndroidApps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * @author Gidy Basin/*from w w w . j av a 2 s . c o m*/ */ package gidy.carpark.utils; import gidy.carpark.ParkingLocation; import gidy.carpark.R; import java.util.List; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; @SuppressLint("ViewHolder") public class LocationsAdapter extends ArrayAdapter<ParkingLocation> { private List<ParkingLocation> locations; private int layoutResourceId; private Context context; public LocationsAdapter(Context context, int layoutResourceId, List<ParkingLocation> items) { super(context, layoutResourceId, items); this.layoutResourceId = layoutResourceId; this.context = context; this.locations = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; LocationHolder holder = null; LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new LocationHolder(); holder.parkingLocation = locations.get(position); holder.locationButton = (Button)row.findViewById(R.id.locationButton); setupItem(holder); row.setTag(holder); return row; } private void setupItem(LocationHolder holder) { String locationStr = holder.parkingLocation.getLocationString(); if (!holder.parkingLocation.hasLocation()){ locationStr += " (??? ?.?.)"; } holder.locationButton.setText(locationStr); } public static class LocationHolder { ParkingLocation parkingLocation; Button locationButton; } }