Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:17:03+00:00 2026-06-05T08:17:03+00:00

I’m doing a small Android app based around a ListView. When the user selects

  • 0

I’m doing a small Android app based around a ListView. When the user selects one or more elements in the list and subsequently selects a menu item from the ActionBar I would like to do a small animation on the selected elements in the list, and this is where things go wrong.

Nothing animates – nor does anything fail. The following code piece is a simplified version of what 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 I messed around with it, trying to figure out what was wrong, I at one point substituted the item with the entire ListView to rule out the animation as the source of the problem – like 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 my amazement, that worked perfect!

So my question is – why can’t I animate the individual elements in a ListView? Or is there something I am doing wrong?

Thanks!

P.S. For the record the ListView is populated with custom views (LinearLayouts), and I have checked that I get the right item before animating.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:17:04+00:00Added an answer on June 5, 2026 at 8:17 am

    I found out what the issue was:

    View v = fragment.getListAdapter().getView(fragment.getListView().getFirstVisiblePosition(), null, null);
    

    This line was the problem. It returns a new View to display the underlying data at the specified position in the list not the existing View. So the returned View has nothing to do with the list.

    Instead doing this:

    View v = fragment.getListView().getChildAt(fragment.getListView().getFirstVisiblePosition());
    

    Got me the View that the list was using and the animation worked as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.