I want to implement CustomArrayAdapter and following is the constructor I have written for my custom adapter
public CustomUsersAdapter(Context context, ArrayList<User> users) {
super(context, 0, users);
}
The second argument in the super call The resource ID for a layout file containing a TextView to use when instantiating views. I dont know which resource ID is being referred here. Can anyone please explain in detail which resource ID is being referred here.
My overridden getView method is as follows :-
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
User user = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_user, parent, false);
}
// Lookup view for data population
TextView tvName = (TextView) convertView.findViewById(R.id.tvName);
TextView tvHome = (TextView) convertView.findViewById(R.id.tvHometown);
// Populate the data into the template view using the data object
tvName.setText(user.name);
tvHome.setText(user.hometown);
// Return the completed view to render on screen
return convertView;
}