Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.TextView;
- import java.util.ArrayList;
- import java.util.List;
- public class ContactAdapter extends ArrayAdapter {
- List list = new ArrayList();
- public ContactAdapter(Context context, int resource) {
- super(context, resource);
- }
- @Override
- public void add(Object object)
- {
- super.add(object);
- list.add(object);
- }
- @Override
- public int getCount()
- {
- return list.size();
- }
- @Override
- public Object getItem(int position)
- {
- return list.get(position);
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View row;
- row = convertView;
- ContactsHolder contactsHolder;
- if (row == null)
- {
- LayoutInflater layoutInflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- row = layoutInflater.inflate(R.layout.list_item,parent,false);
- contactsHolder = new ContactsHolder();
- contactsHolder.tx_kode =(TextView) row.findViewById(R.id.tx_name);
- contactsHolder.tx_nama =(TextView) row.findViewById(R.id.tx_brg);
- contactsHolder.tx_harga =(TextView) row.findViewById(R.id.tx_harga);
- row.setTag(contactsHolder);
- }
- else
- {
- contactsHolder = (ContactsHolder)row.getTag();
- }
- Contacts contacts = (Contacts)this.getItem(position);
- contactsHolder.tx_kode.setText(contacts.getKode());
- contactsHolder.tx_nama.setText(contacts.getNama());
- contactsHolder.tx_harga.setText(contacts.getHarga());
- return row;
- }
- static class ContactsHolder
- {
- TextView tx_kode, tx_nama,tx_harga;
- }
- }
Add Comment
Please, Sign In to add comment