Note that there are some explanatory texts on larger screens.

plurals
  1. POclick listeners for dynaically added imageview
    primarykey
    data
    text
    <p>I have an activity in my app which displays rss feeds and next to each rss feed arrow image is attached.</p> <p>I am new to android any help will be appreciated.</p> <p>i shall explain what i am doing to display rss news ...</p> <p>i have a seperate dummy xml layout for a single rss.. i have set id for arrow image (which will navigate to the next activity) in it as iv_arrow_img i am iterating over the news feeds i get and for each news feed i am adding the dummy view again and again...my question is how will i distinguish between different image arrow's ids .. because for now all are having the same id... how will i set onclick listeners to them ???</p> <p>..... @devA taking ur suggestions i have wrote the code Iterator itr = data.iterator(); int i =0; while (itr.hasNext()) { NewsPostDTO newspostdto = itr.next();</p> <pre><code> view = inflater.inflate(R.layout.rl_news_item, null); lnContentView.addView(view, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); ivArrowfwd = (ImageView) view.findViewById(R.id.iv_arrowfwd); tvNewsHeading.setText(newspostdto.getFeaturedDesc()); tvNewsContent.setText(newspostdto.getDate() + " - " + newspostdto.getTitle()); ivArrowfwd.setId(id); ivArrowfwd.setTag(newspostdto); ivArrowfwd.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View arg0, MotionEvent arg1) { System.out.println("sdfsdf" +(ImageView) view.findViewById(id).getTag()); return false; } }); id++; } </code></pre> <p>but i am not gettng different tags for each news thought they are unique .. can u tell me where i am doing wrong... ?</p>
    singulars
    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.
 

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