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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:14:43+00:00 2026-06-18T12:14:43+00:00

i am trying to do progress dialog before listview are showed because items on

  • 0

i am trying to do progress dialog before listview are showed because items on listview are downloaded.

I get this because i’m trying to change listview in thread with displayListView();

02-08 00:25:48.959: W/System.err(3244): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

If i put displayListView() outside my thread i get nullpointerexeption. displayListView() uses fieldsList arraylist which are downloaded.
I’ve tried to wait while myThread.isAlive, but in this way progressdialog isn’t showed.
How to fix it?

My code:

@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.build_main);
        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setCancelable(true);
        dialog.setMessage("Loading...");
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.setMax(100);
        dialog.show();


        Thread myThread = new Thread(new Runnable() {
            public void run() {


                Builder builder = new Builder(server, user, password, BuildFieldsViewActivity.this, USER_AGENT);
                Document doc = null;
                doc = builder.DownloadPage("d.php?ne="+gyv_id);

                fieldsList = builder.getKaimas(doc);

                displayListView();

                dialog.setProgress(100);
                dialog.dismiss();
            }
        });
        myThread.start();
}
  • 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-18T12:14:44+00:00Added an answer on June 18, 2026 at 12:14 pm

    any UI element must be updated from the UI thread. You are manipulating the dialog from a background thread. Thus, crash happened.

    a quick fix would be to use runOnUiThread(Runnable), inside the runnable, you can update any UI element safely.

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

Sidebar

Related Questions

I am trying to put progress dialog on Click event of ListView as mentioned
I am trying to show progress dialog using this code pd = ProgressDialog.show(v.getRootView().getContext(), ,
I'm trying to implement a thread that shows a progressdialog before loading the listview
I have a layered worker class that I'm trying to get progress reports from.
I'm trying to customise the standard WiX Progress Dialog (I want to make it
I am trying to display a progress dialog during downloading of data. Right now,
I am simply trying to create a spinning progress dialog. No text, no borders,
I have a problem I created my progress dialog dialog = new ProgressDialog(InstallerActivity.this); I
I am trying to add a progress dialog when a new activity is launched
I'm trying to thread wx.ProgressDialog. I got a Progress threading class class Progress(threading.Thread): def

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.