ArrayAdapter custom view state gets repeated when scrolling?

It is caused by View recycling. You should completely refresh the state of your View when getView is called. Although you are refreshing almost everything, you've forgotten one little thing.

It is caused by View recycling. You should completely refresh the state of your View when getView is called. Although you are refreshing almost everything, you've forgotten one little thing.

Suppose the list shows 5 items on screen and the second item is checked. The user then scrolls down a further 5 items - however due to view recycling they're really just the same 5 views as before the user scrolled, so the one of the items on-screen will still be checked even though it shouldn't be, because in your code above if no package is matched you are not setting the checkbox to unchecked (so it will stay checked), you are assuming it is already unchecked (which due to View recycling it may not be). The fix is simple: simply set the checkbox to unchecked before your logic to check if it need be checked: // Do not assume the checkbox is unchecked to begin with, it might not be // if this view was recycled, so force it to be unchecked by default and only // check it if needed.Check.

SetChecked(false); for (Application app : profile.getApps()) { if (info.getPackageName(). Equals(app.getPackageName())) { check. SetChecked(true); break; } }.

This worked, thanks. The only other thing I needed to change to get it to function correctly is to switch my checkbox listener from setOnCheckedChangeListener to setOnClickListener, otherwise anytime a checkbox got reset when recycling the view, it would trigger the handler function. – HotN Sep 24 at 18:23.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions