Weird problem with listview

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Weird problem with listview

Postby setrio » Tue Feb 09, 2010 6:35 pm

Hello,

I have a listview with some customs components on each row, for example a button and a gradientdrawable. I want to update the gradient each time the button is pressed. I get all the code but this is the weird problem...when i click the button for some reason the gradient updated is another gradient from another row, second time is the right gradient and so on.

In the debug i see that the controls id changed on each update of the control, the ids changed from position each time i press the button.

Any ideas?
setrio
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Jan 19, 2010 5:20 pm
Location: Uruguay

Top

Postby azraeal » Wed Feb 10, 2010 12:01 am

Sounds like you are using the ID's of each custom view as its index.

Double check the logic you have in the adapterView implementation.
Also check the onClick logic for the button.

Without code, I can only give vague suggestions.

Also please rephrase
In the debug i see that the controls id changed on each update of the control, the ids changed from position each time i press the button.
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Postby setrio » Wed Feb 10, 2010 12:04 pm

Thanks for the answer azraeal.

Rephrase:
In the debug window, when the button is pressed, i check the id of the controls and that ids changed, in position 0, for example, the ids of the control correspond to the ids that in the previous click was on the position 1.

Also i found a walkaround for this. Previously on each click i refresh the hole listview (notifydatasetchanged), in the new code i only refresh the row (row.invalidate) and now seems to work.

But anyway, i still dont understand why the ids changes if i use notifydatasetchanged.

If still is not clear the problem i post the code.
setrio
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Jan 19, 2010 5:20 pm
Location: Uruguay

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 7 guests