I want to implement CustomArrayAdapter and following is the constructor I have written for my custom adapter
public CustomUsersAdapter(Context context, Array
Try this way,hope this will help you to solve your problem.
class CustomUsersAdapter extends BaseAdapter {
private Context context;
pArrayList users;
public CustomUsersAdapter(Context context,ArrayList users) {
this.context = context;
this.users = users;
}
public class ViewHolder {
TextView tvName;
TextView tvHometown;
}
@Override
public int getCount() {
return users.size();
}
@Override
public Object getItem(int position) {
return users.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = LayoutInflater.from(context).inflate(R.layout.item_user, null);
holder.tvName = (TextView) view.findViewById(R.id.tvHometown);
holder.tvHometown = (TextView) view.findViewById(R.id.tvHometown);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.tvName.setText(users.get(position).name);
holder.tvHometown.setText(users.get(position).hometown);
return view;
}
}