Listview Refresh Android Animation

I have a simple ListView that displays data from a database. Every 1 minute, the data is automatically updated. Here is the code snippet that I use for this:

DataAdapter adp = (DataAdapter) DataList.getAdapter(); adp.UpdateDataList(DataAdapter.DATA_LIST); adp.notifyDataSetChanged(); DataList.invalidateViews(); DataList.scrollBy(0, 0); 

I created a ListView ie a DataView and a dataAdapter that just extends the baseAdapter. UpdateDataList simply retrieves data from the database and creates an array. The adapter notifies the view of the data update.

Everything works perfectly. Now the one thing I'm trying to do here is when the data update I need to add some kind of animation so that it starts to inherit. And people say something happened.

Similar to iPhone. I do not want to add a spinner, because the data update is synchronized, so that the data changes quickly, without any new changes. Just the numbers were flipped.

Any help would be appreciated ....

+4
source share
2 answers

Perhaps you can attach an animation to your list, since ListView extends the ViewGroup, you can do this, read the LayoutAnimationController at android: http://developer.android.com/reference/android/view/animation/LayoutAnimationController.html

amuses

+1
source

Here is the code I tried and worked well for me ....

 /* Setting up Animation */ AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(400); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(400); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f); parent.setLayoutAnimation(controller); /* Animation code ends */ 
+10
source

All Articles