android - How to animate individual elements in ListView -


i'm doing small android app based around listview. when user selects 1 or more elements in list , subsequently selects menu item actionbar small animation on selected elements in list, , things go wrong.

nothing animates - nor fail. following code piece simplified version of i'm doing:

private void animatelistviewitem() {     translateanimation anim = 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);     anim.setduration(2000);     view v = fragment.getlistadapter().getview(fragment.getlistview().getfirstvisibleposition(), null, null);     v.startanimation(anim); } 

when messed around it, trying figure out wrong, @ 1 point substituted item entire listview rule out animation source of problem - this.

private void animatelistviewitem() {     translateanimation anim = 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);     anim.setduration(2000);     fragment.getlistview().startanimation(anim); } 

to amazement, worked perfect!

so question - why can't animate individual elements in listview? or there doing wrong?

thanks!

p.s. record listview populated custom views (linearlayouts), , have checked right item before animating.

i found out issue was:

view v = fragment.getlistadapter().getview(fragment.getlistview().getfirstvisibleposition(), null, null); 

this line problem. returns new view display underlying data @ specified position in list not existing view. returned view has nothing list.

instead doing this:

view v = fragment.getlistview().getchildat(fragment.getlistview().getfirstvisibleposition()); 

got me view list using , animation worked expected.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -