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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:49:31+00:00 2026-05-30T00:49:31+00:00

I have a ListView in which each item has a SeekBar. When I update

  • 0

I have a ListView in which each item has a SeekBar.

When I update the progress of the Seekbar this is written to a database so it can be reloaded when the application is used again.

Unfortunately if the ListView is scrolled up or down so that any of the items disappear from the visible screen, when they are redrawn they are drawn with the old value.

How do I get the activity to “refresh” when the SeekBar is updated so the values behind the ListView are in sync with the database, this should stop the SeekBar being redrawn with stale data.

Update:

I’ve worked out it is due to the underlying ArrayList not being updated, so whilst the database is written to when the progress is updated, the ArrayList is in the same state as when it was originally passed to the constructor. How do I repopulate the ArrayList when I’ve updated the underlying database ?

Code

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
try {
    if (view == null) {
    LayoutInflater vi = (LayoutInflater) mContext
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = vi.inflate(R.layout.task_list_item, null);
    }
    final Task t = mList.get(position);
    if (t != null) {

    /* assign layout elements */
    final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seek);
    final TextView textViewDescription = (TextView) view
        .findViewById(R.id.task_description_text_view);
    final TextView textViewTaskId = (TextView) view
        .findViewById(fyp.proj.R.id.task_id_text_view);
    final TextView textViewTaskTitle = (TextView) view
        .findViewById(R.id.task_title_text_view);

    /* populate layout with task details */
    textViewTaskId.setText(String.valueOf(t.getTaskId()));
    textViewTaskTitle.setText(t.getTaskTitle());
    textViewDescription.setText(t.getTaskDesc());
    seekBar.setProgress(t.getProgress());
    seekBar.setTag(t.getTaskId());

    /* attach listener */
    attachProgressUpdatedListener(seekBar);

    }
} catch (Exception e) {
    Log.i(TaskAdapter.class.toString(), Log.getStackTraceString(e));
}
return view;
}

private void attachProgressUpdatedListener(SeekBar seekBar) {
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

    public void onStopTrackingTouch(SeekBar seekBar) {
    int progress = seekBar.getProgress();
    int task_id = (Integer) seekBar.getTag();

    // task handler instansiated with zero as parent project id is
    // not needed here.
    TaskHandler taskHandler = new TaskHandler(DBAdapter
        .getDBAdapterInstance(getContext()), 0);

    taskHandler.updateTaskProgress(task_id, progress);

    }

    public void onStartTrackingTouch(SeekBar seekBar) {
    // empty as onStartTrackingTouch listener not being used in
    // current implementation

    }

    public void onProgressChanged(SeekBar seekBar, int progress,
        boolean fromUser) {
    // empty as onProgressChanged listener not being used in
    // current implementation

    }
});

}
  • 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-05-30T00:49:32+00:00Added an answer on May 30, 2026 at 12:49 am

    Solution

    As per slukian’s comment the answer in this case was to pass the new progress value back to the underlying mList. Here’s the solution.

    private void attachProgressUpdatedListener(SeekBar seekBar,
        final int position) {
    
    seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
    
        public void onStopTrackingTouch(SeekBar seekBar) {
        int progress = seekBar.getProgress();
        int task_id = (Integer) seekBar.getTag();
    
        // task handler instansiated with zero as parent project id is
        // not needed here.
        TaskHandler taskHandler = new TaskHandler(DBAdapter
            .getDBAdapterInstance(getContext()), 0);
    
        taskHandler.updateTaskProgress(task_id, progress);
    
        // update underlying mList
        mList.get(position).setProgress(progress);
    
        }
    
        public void onStartTrackingTouch(SeekBar seekBar) {
        // empty as onStartTrackingTouch listener not being used in
        // current implementation
    
        }
    
        public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        // empty as onProgressChanged listener not being used in
        // current implementation
    
        }
    });
    
    }
    

    Added position to the attachProgressUpdatedListener method.
    Retrieved the item in the ArrayList at the passed position and updated the progress attribute.

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

Sidebar

Related Questions

I have a ListView in which each item has a complex layout that contains,
I have a listview which has its datasource changed after update of a search
I have been developing Android application which has 3 ListView and one ContextMenu for
I have a listview where each list item can contain 1 or more clickable
I'm developing a touchscreen application, have a listview with a DataTemplate which has a
I have a listview which displays items retrieved from the webpage. Each item in
I have a listview with lists lines of an invoice (Which are editable), each
This is a very common scenario: displaying images in a ListView which have to
This is probably easy as well. But I have this listview which contains exe
I have a ListView, and I want to customize the layout of each item

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.