Skip to content

Instantly share code, notes, and snippets.

@ogulcan
Created February 18, 2012 22:56
Show Gist options
  • Save ogulcan/1861252 to your computer and use it in GitHub Desktop.
Save ogulcan/1861252 to your computer and use it in GitHub Desktop.
Custom ArrayAdapter Example
public class CustomAdapter extends ArrayAdapter<Tip> {
Context context; // LoayutInflater için gerekli.
ArrayList<Tip> objects; // Gelecek verileri karşılamak için gerekli
public CustomAdapter(Context applicationContext, int dovizLayout, ArrayList<String> Tips) {
super(applicationContext, dovizLayout);
this.context = applicationContext;
this.objects = (ArrayList) Tips;
}
@Override
public int getCount() {
return this.objects.size();
}
@Override
public Tip getItem(int position) {
return this.objects.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if(row == null) {
LayoutInflater inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.doviz_list, parent, false);
}
Tip object = getItem(position);
TextView tv1 = (TextView) row.findViewById(R.id.Tip);
TextView tv2 = (TextView) row.findViewById(R.id.textView3);
TextView tv2 = (TextView) row.findViewById(R.id.textView2);
tv1.setText(getValue(object.getField1().toLowerCase()));
tv2.setText(object.getField2());
tv3.setText(object.getField3());
return row;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment