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

  • Home
  • SEARCH
  • 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 5990081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:11:33+00:00 2026-05-22T23:11:33+00:00

Here’s the situation: I’ve got some lengthy non-UI code that needs to be run

  • 0

Here’s the situation: I’ve got some lengthy non-UI code that needs to be run in a ListActivity and then have this ListActivity update the UI to contain a the result of this lengthy method (the list). I need a ProgressDialog to be running until it’s finished so the user has some feedback.

Here’s the code:

public class SolutionListActivity extends ListActivity
{

    private String[] solutions;
    private String letters;
    private ProgressDialog dialog;
    private static Solver solver;


    /** Called when the activity is first created.
     * @param savedInstanceState
     */
    @Override
    public void onCreate(Bundle savedInstanceState)
    { 
        super.onCreate(savedInstanceState);

            //Get the selected letters from LettersActivity
        letters = getIntent().getStringExtra("letters");

        dialog = ProgressDialog.show(this, "Please Wait...",
                    "Searching Words...", true);



        new Thread()
        {
            @Override
            public void run()
            {
                if (solver == null) 
                {
                    solver = new Solver(SolutionListActivity.this);
                    solver.readDictionary(0);
                    solver.readDictionary(1);
                }
                solutions = solver.solve(letters);

                runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        dialog.dismiss();
                        //Set up a UI List
                        setListAdapter(new ArrayAdapter<String>(SolutionListActivity.this, R.layout.list_item, solutions));

                        ListView lv = getListView();
                        lv.setTextFilterEnabled(true);


                    }
                });

            }
        }.start();

The problem is my ProgressDialog won’t dismiss and I can’t be sure whether the solutions = solver.solve(letters); will be finished before the UI uses it in setListAdapter(new ArrayAdapter<String>(SolutionListActivity.this, R.layout.list_item, solutions));

Any advice you guys have would be helpful.

Thank You,
Calum

  • 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-22T23:11:34+00:00Added an answer on May 22, 2026 at 11:11 pm

    Have you tried AsyncTask? It´s built exactly for having threading AND be able to update things in your UI Thread.

    Take a look here: http://developer.android.com/resources/articles/painless-threading.html

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

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is my code, which takes two version identifiers in the form 1, 5,
Here is the scenario: I'm writing an app that will watch for any changes
Here we go again, the old argument still arises... Would we better have a
I have just tried to save a simple *.rtf file with some websites and
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote

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.