I have simple ListView that displays data from database. Every after 1 min data are getting refresh automatically. Here is the code snippet I am using to do that :
DataAdapter adp = (DataAdapter) DataList.getAdapter();
adp.UpdateDataList(DataAdapter.DATA_LIST);
adp.notifyDataSetChanged();
DataList.invalidateViews();
DataList.scrollBy(0, 0);
I have created ListView i.e. DataView and dataAdapter that simply extends baseAdapter. UpdateDataList is simply get data from database and creates an arrayList. And Adapter notifies view to refresh the Data.
Everything is working perfect. Now one thing I am trying to do here is when data refresh I need to add some kind of animation so that it becomes eyecaching. And people mark that something happened.
Similar to iPhone application. I do not want to add spinner because data update is synchronize process so data change is quickly without making any new changes in view. Simply numbers got flipped.
Any help will be appreciated....
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 */
Maybe you can attach an animation to your ListView, since ListView extends ViewGroup you can do it, read the LayoutAnimationController on android reference: http://developer.android.com/reference/android/view/animation/LayoutAnimationController.html
cheers
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