I have been trying desperately to fix this issue where my ListView items are highlighted. I have reviewed any solution I could find here on stackoverflow, and have found none that work for me.
First off, this is a ListView in a LinearLayout in a ViewPager in a LinearLayout.
Each Item in that Listview is a LinearLayout containing a LinearLayout (Containing a TextView) and a Gallery. The Gallery contains multiple LinearLayouts containing a TextView and Imageview in a FrameLayout.
This problem occurs, not on click but on drag, as when swiping your finger over a story (sometimes while the ListView scrolls with your drag) the item underneath becomes selected. Additionally, this particular problem only occurs on devices where the over-scroll effect does not cause a bounce when scrolling.
Attempts to solve the issue are as follows:
Set the List Selector to the Background Color in XML (Fail)
Set the List Select to Alpha #00000000 in XML (Fail)
The Above but Programatically
The Above but by theme
Code that sets the selection to -1 onListItemClick
Removing the background from list item's LinearLayout (Works on 4.0)
Setting android:cacheColorHint to #00000000 (does nothing?)
I just can't figure out why it's doing this and I really need it to stop.
This was a most interesting problem. The solution of which is even more interesting.
For some reason, what I didn't try, and what nobody thought of, was to remove android:background from the LinearLayout for the ListView items.
Upon removing android:background, the layout continues to display properly and the black no longer appears.
If you have a problem similar to this that this does not solve, you may want to check the Android Blog: Why is my list black?
EDIT: This worked fine for ICS, but elicited a much larger problem in 2.1. To completely solve the ordeal, I ended up having to specify android:cacheColorHint="#000000" to the ListView (and the LinearLayout for good measure) in my inline styles as well as in the style definition I applied to the ListView.
Related
I have a Layout with a ToggleButton and a gallery.
I'd like to change the toggleButton when I'm scrolling, I've implemented OnItemeSelectedListener and depending of the object I'm setting the button checked or not.
The thing is that the scroll freezes when the ToggleButton is changing, I know that there is only one thread for the UI but could I improve it?
I've seen apps like the CNN one which changes items like a textView color while scrolling, so should be a way...
The problem was the ToggleButton, I can change drawables, textviews and other items whitout problems but it seems that ToggleButton.setChecked is a slow code.
Finally I have two ToggleButtons overlapped, one to on and the other one to off and I make the top one visible or invisible.. apparently it's the same and it faster now :).
I would like to change the default behaviour of my listview, so when im scrolling to the last item, the list will keep scrolling untill the last item is at the top of the list.
default behaviour stops scrolling when the last item is fully in view.
Any ideas on how i can go about this pre 2.3?
Thanks,
Totem.
In case anyone is interested in the solutions available it either:
1) add to the list view padding, that solution forces you to play around with the fading edge property since it gets sifted because of thee padding. also this method might not work well if your using a transparent background because items will be rendered and visible under the padding area. Although this could be fixed by entering the list into a relative layout and making sure to draw something over that area.
2) add transparent items to the listview for offset and not set them as enabled to avoid dividers, just need to make sure to change getItemCount and getItemTypeCount and so on if your if your item isn't really inside your adapter as per my case.
I went with option two.
Thanks,
Totem.
I have an ImageView on top of a ListView and whenever there is a long running process to populate the list I would like to hide the ListView and make the ImageView visible.
I tried some things with setVisibility() but I'm getting messed up scroll behavior for the list.
I'm using AsyncTask to manage all this but I don't think that's causing the messed up scrolling behavior. Any ideas on how I can display a busy spinner while the list is being populated and not get inconsistent scrolling behavior for the list?
As far as the weird scrolling behavior you may need to set this property on your listview android:cacheColorHint to #00000000
Otherwise it will do weird things when there is an image under the ListView while scrolling.
I have a LinearLayout layout with a ListView in it. I've made the android:background of the LinearLayout (I've also tried it on the ListView) be an image that I would like for my background.
This works fine enough. However, when I start scrolling through the ListView, the background often disappears and becomes black. If I move it around some more I may be able to get it to appear again. It would seem that Android is drawing over, or perhaps painting what's behind my background onto the items.
Any ideas/solutions?
android:cacheColorHint="#00000000" on your listview
More info is here
http://www.curious-creature.org/2008/12/22/why-is-my-list-black-an-android-optimization/
I am using a couple of ListView elements in my app. In all cases, it doesn't highlight the selected item when I click/touch it, but I can use the trackball to scroll up and down, and can see the orange highlighted color then. How do I fix this?
For e.g., one of them is a LinearLayout with two TextViews in it.
Setting the background to the list_selector_background for the parent Layout element for each of the items did the trick.
android:background="#android:drawable/list_selector_background"