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 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

I have just tried to save a simple *.rtf file with some websites and
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's my code: delegate.h #import <UIKit/UIKit.h> @class _4_Control_FunViewController; @interface _4_Control_FunAppDelegate : NSObject <UIApplicationDelegate> {
Here is my code. My question has to do with the append function inside
Here i make 5 Tab buttons that are working proper but now i want
here is the code : http://jsfiddle.net/yuliantoadi/hMr7h/ if you try to hover the 'test 2'
Here's task: We have an sql server database. which is hosted at our server.
Here's the page in question: http://bit.ly/m5cyjx There's hardly any code or styling. It seems
Here's a simple, 45 line console application that reproduces the bug on my Win
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.