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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:31:56+00:00 2026-06-01T01:31:56+00:00

ProgressDialog onClick not working.. here is my code .. Basically i want to show

  • 0

ProgressDialog onClick not working.. here is my code .. Basically i want to show loading dialog when user submits login form and waits for response

public class LoginLayout extends MenuActivity {
ProgressDialog progress;
EditText un,pw;
TextView error;
Button ok;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);
    un=(EditText)findViewById(R.id.et_un);
    pw=(EditText)findViewById(R.id.et_pw);
    ok=(Button)findViewById(R.id.btn_login);
    error=(TextView)findViewById(R.id.tv_error);

    ok.setOnClickListener(new View.OnClickListener() {

        @Override

        public void onClick(View v) {
                progress = ProgressDialog.show(LoginLayout.this, "Login","please...wait",true);

            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));

            String response = null;
            try {

                response = CustomHttpClient.executeHttpPost("http://www.mysite.com/api/login.php", postParameters);
                String res=response.toString();
                res= res.replaceAll("\\s+","");
                progress.dismiss();

        if(res.equals("1"))
                    error.setText("Correct Username or Password");
                else
                    error.setText("Sorry!! Incorrect Username or Password");
            } catch (Exception e) {
                un.setText(e.toString());
            }

        }
    });
}

}

  • 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-01T01:31:57+00:00Added an answer on June 1, 2026 at 1:31 am

    You have to use Hanlders or AsyncTask. There are numerous questions regarding this here. Try to follow the below snippet,

    Do this in your onCreate()

           Handler handler;
    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
         Pdialog.dismiss();     
    
     if(res.equals("1"))
                    error.setText("Correct Username or Password");
                else
                    error.setText("Sorry!! Incorrect Username or Password");
         }
       };
    

    And now use a thread to upload files to server. Modify this piece of code,

    public class Activity001 extends Activity 
    {
    
    ok.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) 
         { 
        ProgressDialog progressDialog = ProgressDialog.show(Activity001.this, "", "wait ", true, false);
    Thread ProgressThread = new Thread() {
                    @Override
                    public void run() {
                        try {
    
    ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
                postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
                postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));
    
                String response = null;
                try {
    
                    response =         CustomHttpClient.executeHttpPost("http://www.mysite.com/api/login.php", postParameters);
                    String res=response.toString();
                    res= res.replaceAll("\\s+","");
    
    
                            } catch(InterruptedException e) {
                                // do nothing
                            } finally {
    
                                     handler.sendEmptyMessage(0);
                            }
                        }
                    };
    
                        ProgressThread.start();
    
    
               } };
    
        }
    

    If not go for AsyncTask,

    Here are few links,

    http://www.vogella.de/articles/AndroidPerformance/article.html

    http://labs.makemachine.net/2010/05/android-asynctask-example/

    http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

The code snippet below displays a Dialog with a simple login-form. The problem is
Possible Duplicate: Android: ProgressDialog.show() crashes with getApplicationContext I want to have a progress dialog
I can't make my ProgressDialog show up and I'm not sure why? The Code:
I want ProgressDialog to show while my code enables WiFi and connects to a
Here is my code segment I am trying to dismiss dialog but it is
I am showing my alert dialog in a separate thread and its not working
I have a progress dialog I am trying to show when a user clicks
I'm trying to test an Activity in android which will show a ProgressDialog and
to show a background process i used ProgressDialogBox . My code is as add_button.setOnClickListener(new
This is my current code: public void onClick(View v) { final Intent pickIntent =

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.