• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to refer a view in a line inside a ListView ?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I generated a ListView (using a simple BaseAdapter) where each line is made of:

ButtonDOWN -- TextArea -- ButtonUP

The idea is that when clicking on the buttons the value of the textarea must increase|decrease.

this is the XML of the single line:



In the Activity this is the OnClickButton code:



The problem is when two or more lines are listed, and I click on the buttons, only the textarea of the first line is updated,
even if I click on the buttons of the other lines!

How I can point to the right textarea ?
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use Custom Adapter. In that you will be having getView Method in which you have inflated view for each list item. Implement you button's click event in that getView method only. So each button will have a separate click listener.Implement logic in that.

Hope you got your answer.

Or correct me if I got your question in wrong manner.
 
Alessandro Camel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hardik Trivedi wrote:Use Custom Adapter. In that you will be having getView Method in which you have inflated view for each list item. Implement you button's click event in that getView method only. So each button will have a separate click listener.Implement logic in that.

Hope you got your answer.

Or correct me if I got your question in wrong manner.



Thanks Hardik,indeed this is the rigth solution.
Implementing the event handlers inside the getView method is the rigth way to solve this!
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic