How can I animate newly added items in ListView
?
I have a adapter
and when I add new items in my list I say adapter.notifyDataSetChanged();
the items are added, everything works perfectly, but my problem is I want newly added element to have some animation.
Animate
each added element in the getView()
method of your Custom Adapter
.
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.simple_list_item_1, null);
}
ListData o = list.get(position);
TextView tt = (TextView) v.findViewById(R.id.toptext);
tt.setText(o.content);
Log.d("ListTest", "Position : "+position);
if(flag == false) {
Animation animation = AnimationUtils
.loadAnimation(getActivity(), R.anim.slide_top_to_bottom);
v.startAnimation(animation);
}
return v;
}
And thereby achieve the Animation
.
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