Note that there are some explanatory texts on larger screens.

plurals
  1. POsetId() and getId() on custom listView item giving unexpected result
    primarykey
    data
    text
    <p>I have created custom listview in which i have</p> <p><code>textView,imageView</code>.</p> <p>I want to <strong>set id</strong> to the <strong>each row's imageView</strong> so that when i click on that image,can get the id(for the purpose of uniqueness).I have also a click listener in getView.So I want to get that id on click of that particular image but when i click on that image everytime i am getting 3,I don't no why this is happening.Any help would be appreciable.</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { final CruunNotificationModel cruun = userDetails.get(position); LayoutInflater mInflater = (LayoutInflater) context .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = mInflater.inflate(R.layout.imagewithlist, parent, false); holder = new ViewHolder(); holder.userName = (TextView) convertView .findViewById(R.id.userNameTextView); holder.userTask = (TextView) convertView .findViewById(R.id.userTaskTextView); holder.dateTime = (TextView) convertView .findViewById(R.id.dateTimeTextView); holder.userComments = (TextView) convertView .findViewById(R.id.userCommentsTextView); holder.userImage = (ImageView) convertView .findViewById(R.id.userImageImageView); holder.expandImage = (ImageView) convertView .findViewById(R.id.expandTextImageView); holder.commentPart = (LinearLayout) convertView .findViewById(R.id.commentlayout); holder.view = (View) convertView.findViewById(R.id.view); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); holder.userComments.setText(cruun.getComments()); holder.userName.setText(cruun.getUserName()); holder.userTask.setText(cruun.getUserTask()); holder.dateTime.setText(cruun.getDateAndTime()); holder.userImage.setImageResource(cruun.getImageId()); holder.expandImage.setImageResource(R.drawable.down_arrow); holder.expandImage.setId(position); holder.expandImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { holder.userComments.setEllipsize(null); RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lParams.setMargins(2, 10, 2, 0); holder.userComments.setMaxLines(Integer.MAX_VALUE); lParams.addRule(RelativeLayout.BELOW, R.id.userImageLayout); holder.userComments.setLayoutParams(lParams); holder.expandImage.setImageResource(R.drawable.up_arrow); notifyDataSetChanged(); if (v.getId() == holder.expandImage.getId()) { holder.view.setVisibility(View.VISIBLE); holder.commentPart.setVisibility(View.VISIBLE); } } }); return convertView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload