Created
September 2, 2015 09:47
-
-
Save saturov/93187d2416b838892e45 to your computer and use it in GitHub Desktop.
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
public class TuningAdapter extends ArrayAdapter<Tuning> { | |
private ArrayList<Tuning> tunings; | |
private Context context; | |
private int itemLayout; | |
public TuningAdapter(Context context, int itemLayout, ArrayList<Tuning> tunings) { | |
super(context, itemLayout, tunings); | |
this.context = context; | |
this.itemLayout = itemLayout; | |
this.tunings = tunings; | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View row = convertView; | |
TuningsHolder holder; | |
if (row == null) { | |
LayoutInflater inflater = ((Activity) context).getLayoutInflater(); | |
row = inflater.inflate(itemLayout, parent, false); | |
holder = new TuningsHolder(row); | |
row.setTag(holder); | |
} else { | |
holder = (TuningsHolder) row.getTag(); | |
} | |
holder.populateFrom(tunings.get(position)); | |
return (row); | |
} | |
private class TuningsHolder { | |
private TextView tuningName; | |
private TextView tuningNotes; | |
TuningsHolder(View row) { | |
tuningName = (TextView) row.findViewById(R.id.tuning_name); | |
tuningNotes = (TextView) row.findViewById(R.id.tuning_notes); | |
} | |
void populateFrom(Tuning tuning) { | |
tuningName.setText(tuning.getName()); | |
tuningNotes.setText(tuning.getTuning()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment