Weird list behavior in android - android

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.

Related

Center aligned selection with animation in ListView (?)

I need a component that works like the picture below but I'm having trouble coming up with some kind of decent solution that works.
I want the list to have a center locked selection but being scrollable with the d-pad. This is for an application running on a TV so no need for touch scroll. So when pressing down on the remote d-pad the list will scroll and a new item will size up and the current selected one will size down and the new selection will still be in the middle.
I've tried doing this using a ListView that I extended and programmatically scrolling when pressing down or up. On scroll finished I called notifyDatasetChanged() on the ListView for re-inflating of the childs and in the ListViews adapters getView() I made the animation of the view located at the current selected position.
This is not optimal since I need to call notifyDatasetChanged(), which re-inflates all visible views, for the animation to apply. The UI becomes laggy when doing this and scrolling fast. It's also not possible to make som kind of compress animation when current selected item goes out of selection. There is also some trouble with the end items (read views) such the first or last in the list when doing animation of them, the may sometimes go out of screen.
I think that his must have been done before and maybe I'm missing it when searching for an answer.
Have anyone done something similar or do you have some suggestions of how this can be achieved? Maybe I'm just starting of with the wrong component here..
Regards,
Kristoffer

How do I hide or show adapters/views using cwac-merge?

I have a fragment holding several lists, as you may guess the scrolling is a mess, so I give it a try to the cwac-merge adapter, it seems to do it's job fine, but I wanted to customize some of the items, i.e. I need some of the adapters to show or hide depending on how many items they have, right now empty list adapters are showing a blank space, and I would like to make them gone until items are retrieved.
On the screenshot (please excuse its blurred but Im not allowed to show the product yet) you can see I highlighted with red rectangles the empty spaces, where I'm setting the view to have Visibility = GONE.
Also one of these empty spaces is caused because an adapter has no items.
Is there a way to hide or show certain adapters or views inside the MergeAdapter so they don't occupy space?
Thanks
where I'm setting the view to have Visibility = GONE
IIRC, having a GONE row in a ListView is problematic in general. MergeAdapter should not have an impact on it.
Also one of these empty spaces is caused because an adapter has no items.
I rather doubt that. Hierarchy View should show you what is really going on.
Is there a way to hide or show certain adapters or views inside the MergeAdapter so they don't occupy space?
An adapter returning 0 from getCount() should occupy no space, if you call notifyDataSetChanged() on the MergeAdapter so that it can tell the ListView to redraw itself.

How to prevent ListView items highlighting in Black

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.

Android Scroll ListViewfrom code

I'm trying to have a piece of code cause a ListViewto scroll. This is happening as another view is being scrolled. Currently I'm calling scrollBy(x,y) on this ListView to cause it to scroll. This causes the items in the list to scroll but does not cause new items to be loaded. I've tried calling invalidate on the list but this does not seem to work. The problem appears to be that what the list understands as visible items are only updated by touch events.
Does anyone know a way to get around this?
I think the problem is that ScrollBy and ScrollTo are methods of the base View, and thus seems to be scrolling the whole 'viewport' of the list.
If you want to scroll the items use smoothScrollBy or smoothScrollToPosition.
That should work

Android listview (array adapter) custom scrolling

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.

Categories

Resources