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 8611333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:20:59+00:00 2026-06-12T04:20:59+00:00

I have a ListView which is taking data from DB. Each row when clicked

  • 0

I have a ListView which is taking data from DB. Each row when clicked animates to the right and back as follows:

@Override
    public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

...
          pos = pos - mList.getFirstVisiblePosition();
          mList.getChildAt(pos).startAnimation(anim );
...}

the animation lasts about 1sec and is : slide out right then slide in back

This part works fine if there is no interaction with DB during the animation

Now, each item from the list has a counter in DB. Whenever user clicks on the item from the list the counter should be increased in DB and that is visually presented on the ListView per item as well.

So, DB is visible through ContentProvider

This is the issue :

Whenever I click on an item the animation starts, and then the update is performed to DB through ContentResolver. The problem is that the animation starts at the proper element but just right after it starts it suddenly stops and is finished on other element from the list.

So if I have four elements on the list

----------1----------
----------2----------
----------3----------
----------4----------

and I click element 1, number 1 starts sliding right but after around 200ms it stops and element 4 continues to animate from the place where 1 stopped for the rest of the animation

Same can be reproduced if I press 2 but this time number 3 finishes animation.
If 3 then 2 finishes. If I click 4 then 1.

Assuming only 4 items are visible I can reproduce it throught whole list.

It is always the opposite element. I debug the position in onItemClick, but it is always right.

IMPORTANT
When I comment out the code that makes the update in DB, everything works fine. Which suggests that the problem occurs when SimpleCursorAdapter of ListView is refreshed with new Cursor through LoaderManager from the DB during the animation.

WHAT I did try
using CommonsWare Loaderex instead of ContentProvider. It gives the same effect.

CODE SNIPPETS

public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
  return new CursorLoader(this.getActivity(), MyContentProvider.CONTENT_URI,
            new String[]{}, "uid>0 AND distance<80000", null, "distance LIMIT 100");
}


public void onLoadFinished(Loader<Cursor> ld, Cursor c) {
    merchantAdapter.swapCursor(c);
}

OnItemClick has this code :

ContentResolver cr = getActivity().getContentResolver();
                ContentValues cv = new ContentValues();
                cv.put("counter", counter);
                Uri mUri = ContentUris.withAppendedId(MyContentProvider.CONTENT_URI, uid);
                cr.update(mUri, cv, null, null);

What also bugs me that I wasnt able to make the LoaderManager update the list for me automatically so after above cr.update(…

I do this to refresh the list after each update

getActivity()).lm.getLoader(0).forceLoad();

Could the animation problem be Android bug? or what I am missing?

Current idea to solve this
I guess my option is to block clicks for animation duration and make cr.update in handler after animation duration has passed so that the refresh will not affect animation.

Please advise

  • 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-12T04:21:00+00:00Added an answer on June 12, 2026 at 4:21 am

    I can now confirm that :
    the behaviour only happens on my 2.2 device. And it can be reproduced.
    It works fine (the animation finishes properly when rows are updated in the bg) on Android 4.1 device and it can be reproduced.

    My current solution to this is
    Since I want to support 2.2 devices. I create listener to this animation. when anim is finished I make the update to db. Also I block UI for the duraiton of anim (it is around 300ms so its fine)

    NOTE – this does look like Android SDK problem

    As for the update problem and using forceLoad
    In my content provider implementation I had to add this inside my query method :

    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    

    which is registering this uri to ContentResolver. now it works fine without using forceLoad

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

Sidebar

Related Questions

I have a listview which loads its data from sqlite database. Each row in
I have a ListView which I've created a custom view for each row. My
I have a listview which displays items retrieved from the webpage. Each item in
I have a listview which I am populating with a custom SimpleCursorAdapter, each row
I have ListView which as one TextView in each Row. and im discovering some
I have ListView which is saving all data to database. For adding i have
I have a ListView which contains custom rows. This custom row has following UI
I have listView in which I inflate a row contain textview and button now
i have a ListView which contains objects bound from an collection. The representation of
I have ListView which shows images from an ImageList. Now wanted to get index

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.