Adding Animation To A List View In Android
I want to animate the items of the list view. At Present i am applying the Transition Animation on the list items whenever new items are added. But this is not the animation i want
Solution 1:
I got the Solution to this. I animate each added element in the getView method of my Custom Adapter.
public View getView(int position, View convertView, ViewGroup parent) {
Viewv= convertView;
if (v == null) {
LayoutInflatervi= (LayoutInflater) getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.simple_list_item_1, null);
}
ListDatao= list.get(position);
TextViewtt= (TextView) v.findViewById(R.id.toptext);
tt.setText(o.content);
Log.d("ListTest", "Position : "+position);
if(flag == false) {
Animationanimation= AnimationUtils.loadAnimation(getActivity(), R.anim.slide_top_to_bottom);
v.startAnimation(animation);}
return v;
}
And thereby achieved the animation as i had stated for.
Post a Comment for "Adding Animation To A List View In Android"