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 trialahmet yuva
17,595 Pointshow can i open setitemonclicklistener in this class ? i want to click one item in list and open in detail view
in this list view when i click on one row then it should open in new intent and set details of this row in one page. how is it possible ?
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder;
if (convertView == null) {
// brand new
convertView = LayoutInflater.from(mContext).inflate(R.layout.film_list_item, null);
holder = new ViewHolder();
holder.nameLabel= (TextView) convertView.findViewById(R.id.nameLabel);
holder.emailLabel= (TextView) convertView.findViewById(R.id.emailLabel);
holder.genderLabel= (TextView) convertView.findViewById(R.id.genderLabel);
holder.addressLabel= (TextView) convertView.findViewById(R.id.addressLabel);
holder.imageId= (ImageView) convertView.findViewById(R.id.imageId);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
Film day = mFilmler[position];
byte[] decodedString = Base64.decode(String.valueOf(holder.imageId), Base64.URL_SAFE);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
holder.nameLabel.setText(day.getName());
holder.emailLabel.setText(day.getEmail());
holder.genderLabel.setText(day.getGender());
holder.addressLabel.setText(day.getAddress());
holder.imageId.setImageURI(Uri.parse(day.getImage()));
return convertView;
}
private static class ViewHolder {
TextView nameLabel; // public by default
TextView emailLabel;
TextView genderLabel;
TextView addressLabel;
ImageView imageId;
}
1 Answer
Jon Kussmann
Courses Plus Student 7,254 PointsYou should be able to set on OnClickListener for the listview that you instantiate to attach the adapter.