public class ReceiptAdapter extends BaseAdapter implements Filterable { private final Activity context; public ReceiptAdapter(Activity context) { this.context = context; } class ViewHolder { protected TextView number; protected TextView name; protected ImageButton imageButton; } @Override public View getView(final int position, View convertView, ViewGroup parent) { View view = null; try { if (convertView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.receipt_item, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.number = (TextView) view .findViewById(R.id.tvnumber); viewHolder.name = (TextView) view.findViewById(R.id.tvname); viewHolder.imageButton = (ImageButton) view .findViewById(R.id.delete_item); view.setTag(viewHolder); } else { view = convertView; } ViewHolder holder = (ViewHolder) view.getTag(); holder.name.setText(mContactList.get(position).getName()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return view; } @Override public int getCount() { // TODO Auto-generated method stub return mContactList.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } }
Tuesday, 22 September 2015
Listview adapter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment