Code example for CursorAdapter

0
 
class SampleContactsAdapter extends CursorAdapter {
  private final LayoutInflater inflater;
 
  public SampleContactsAdapter(Context context) {
    super(context, null, 0);
    inflater = LayoutInflater.from(context);
  } 
 
  @Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
    View itemLayout = inflater.inflate(R.layout.sample_contacts_activity_item, viewGroup, false);
 
    ViewHolder holder = new ViewHolder();
    itemLayout.setTag(holder);
 
    holder.text1 = (TextView) itemLayout.findViewById(android.R.id.text1);
    holder.icon = (QuickContactBadge) itemLayout.findViewById(android.R.id.icon);
 
    return itemLayout;
  }