Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

how 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
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

You should be able to set on OnClickListener for the listview that you instantiate to attach the adapter.