I'm stuck, and I haven't been able to find a solution for this anywhere. :(
I have an ImageView inside my Layout of each item of my ListView ( GridView ), provided by a BaseAdapter. When the Images are loaded and I assign the loaded BitmapDrawable to the ImageView using
imageView.setImageDrawable( newImage );
the item pops up without any problems.
BUT if I assign the new BitmapDrawable by using a TransitionDrawable OR by assigning a simple Animation:
//this is inoperative - animation will not start for currently displayed items! No solution found :(
Animation a = LibResource.getResourceAnimation( activity, R.anim.fade_in );
imageView.setImageDrawable( newImage );
imageView.startAnimation( a );
The Animation will not start for CURRENTLY DISPLAYED ITEMS of my GridView. If I scroll down the GridView and scroll it back to the mentioned item, the Image is shown and the Animation has been performed!
I've already tried the following fixes:
imageView.invalidateDrawable( newImage );
imageView.invalidate();
I've also tried the following Statements after assigning the Animation - Of course, I called them ON THE UI-Thread, AFTER assigning and starting the Animation ON THE UI-THREAD:
myGridView.invalidate();
myGridView.invalidateViews();
myGridView.getAdapter().notifyDataSetChanged();
As mentioned, this problem only occurs FOR VISIBLE ITEMS in my ListView.
Why does the Animation or TransitionDrawable not start, even after invoking invalidate() etc. on all involved views?
The Problem occurs on my XPeria-Arc-S ( API-Level 10 ) and in the Android-Emulators API-Level 8,9,10.. Is this a bug in the Android System?
Any help would be greatly appreciated!
Thanks in advance
Christopher
Ok - Thanks for your quick reply.
I got the Problem and after a lot of time of reorganizing my code structure for this to work, I came to the point that this did NOT solve my Problem :(.
Beside this, it is NOT applicable or very practical for me to change contents in the creation of the view. Maybe you have any other Solutions regarding this issue?
Sincerely
Christopher
invalidateViews()
.getView
is called on adapter create view and animate it.I've solved this problem.
Starting animations in views for currently visible ListView/GridView-items will not work if you try to assign this Animation to a referenced component of this item.
Instead, you have to invalidate the GridView
myGridView.invalidateViews()
and start the Animation in the according
getView()
method of the connected BaseAdapter.
Though this method is being invoked very often by the system, you normally use a mechanism that caches all views. So if you want to start an Animation in a specific item, you just recreate the view and the next time the system invokes getView() after calling myGridView.invalidateViews(), the animation will start properly!
Thanks to the user who removed his helpful answer.
Greetings Christopher
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With