I have a listView with about 20 items (dynamic items). I want to animate these items first they show up to user. something like Google+ cards. There are some points that I want
I've just tried this and it seems to meet all of your requirements:
boolean[] animationStates;
public void YourConstructor(...) {
...
animationStates = new boolean[data.size()];
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// (Re)Use the convertView
if (convertView == null) {
convertView = mInflater.inflate(R.layout.popup_list_item, parent, false);
if (!animationStates[position]) {
Log.e("TAG", "Animating item no: " + position);
animationStates[position] = true;
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
animation.setStartOffset(position*500);
convertView.startAnimation(animation);
}
}
// Use convertView here
return convertView;
}
Here's my fade_in.xml file if you're interested:
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>