Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Abeer a
1,191 Pointscustom Adapter for list
how to add two more arguments in Customlistadapter , see below:
public class Customlistadapter extends ArrayAdapter { String[] color_names; String[] color_des;
Integer[] image_id;
Context context;
public Customlistadapter(Activity context, Integer[] image_id, String[] text, String[] text2){
super(context, R.layout.list_row_sponser, text);
// TODO Auto-generated constructor stub
this.color_names = text;
this.color_des=text2;
this.image_id = image_id;
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View single_row = inflater.inflate(R.layout.list_row_sponser, null,
true);
TextView textView = (TextView) single_row.findViewById(R.id.title);
TextView textView2 = (TextView) single_row.findViewById(R.id.artist);
ImageView imageView = (ImageView) single_row.findViewById(R.id.sponserImage);
textView.setText(color_names[position]);
textView2.setText(color_des[position]);
imageView.setImageResource(image_id[position]);
return single_row;
}
}