Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomArrayAdapter extends ArrayAdapter<Contacts>{
- private Context context;
- private int resource;
- public CustomArrayAdapter(@NonNull Context context, int resource, @NonNull List<Contacts> objects) {
- super(context, resource, objects);
- this.context = context;
- this.resource = resource;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent){
- Contacts contacts = getItem(position);
- if(convertView == null){
- convertView = LayoutInflater.from(context).inflate(resource,
- parent, false);
- }
- TextView viewID =convertView.findViewById(R.id.listViewID);
- viewID.setText(contacts.getID());
- TextView viewName =convertView.findViewById(R.id.listViewName);
- viewName.setText(contacts.getName());
- TextView viewAddress =convertView.findViewById(R.id.listViewAddress);
- viewAddress.setText(contacts.getAddress());
- TextView viewPhone =convertView.findViewById(R.id.listViewPhone);
- viewPhone.setText(contacts.getPhone());
- TextView viewEmail =convertView.findViewById(R.id.listViewEmail);
- viewEmail.setText(contacts.getEmail());
- return convertView;
- }
- }
Add Comment
Please, Sign In to add comment