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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:59:33+00:00 2026-06-15T23:59:33+00:00

I use example from http://startandroid.ru/uroki/vse-uroki-spiskom/128-urok-67-dialogi-progressdialog.html We have two buttons. onClick first button – show

  • 0

I use example from http://startandroid.ru/uroki/vse-uroki-spiskom/128-urok-67-dialogi-progressdialog.html

We have two buttons.
onClick first button – show some progress dialog.

onClick second button – show some progress dialog.

If I click fast on first button after that on second button then it is showing two progress dialogs. How to disable this posibility?(Is it good to disable this two buttons when is clicked one of them, or disable LinearLayout, …)

strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="dflt">Обычный</string>
<string name="horiz">Горизонтальный</string>
<string name="app_name">ProgressDialog</string>
</resources>

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">
<Button
 android:id="@+id/btnDefault"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/dflt"
 android:onClick="onclick">
</Button>
<Button
 android:id="@+id/btnHoriz"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/horiz"
 android:onClick="onclick">
</Button>
</LinearLayout>

MainActivity.java:

package ru.startandroid.develop.p0671progressdialog;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

public class MainActivity extends Activity {

  ProgressDialog pd;
  Handler h;

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

  }

  public void onclick(View v) {
    switch (v.getId()) {
    case R.id.btnDefault:
      pd = new ProgressDialog(this);
      pd.setTitle("Title");
      pd.setMessage("Message");
      // добавляем кнопку
      pd.setButton(Dialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
      });
      pd.show();
      break;
    case R.id.btnHoriz:
      pd = new ProgressDialog(this);
      pd.setTitle("Title");
      pd.setMessage("Message");
      // меняем стиль на индикатор
      pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      // устанавливаем максимум
      pd.setMax(2148);
      // включаем анимацию ожидания
      pd.setIndeterminate(true);
      pd.show();
      h = new Handler() {
        public void handleMessage(Message msg) {
          // выключаем анимацию ожидания
          pd.setIndeterminate(false);
          if (pd.getProgress() < pd.getMax()) {
            // увеличиваем значения индикаторов
            pd.incrementProgressBy(50);
            pd.incrementSecondaryProgressBy(75);
            h.sendEmptyMessageDelayed(0, 100);
          } else {
            pd.dismiss();
          }
        }
      };
      h.sendEmptyMessageDelayed(0, 2000);
      break;
    default:
      break;
    }
  }
}
  • 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-15T23:59:34+00:00Added an answer on June 15, 2026 at 11:59 pm

    Instead of disabling views just create a boolean variable that you set to true when a dialog is clicked. In your onClick function you can check if there is already an active dialog. Then you can add an onDismissListener to your dialogs and reset the boolean variable.

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

Sidebar

Related Questions

I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python
I have downloaded the example code/demo from: http://www.technowise.in/2009/12/uploadify-aspnet-c-vb-examples-demo.html and when I try to run
I'm trying to implement a simple TPH example from http://msdn.microsoft.com/en-us/library/dd793152.aspx . I have two
I use some HTTP Handlers from my Web Forms days forms, to for example
I'm trying to compile a boost tutorial example from http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/tutorial/tuttimer1.html . My CMakeLists.txt looks
I have been looking at a HTML 5 boilerplate template (from http://html5boilerplate.com/ ) and
I try to use this example to get images urls from http://www.nydailynews.com/cmlink/NYDN.Article.rss but no
I am studying Backbone and the todo example apps from http://todomvc.com/ I have noticed
Try to use the FEST-Swing for Swing GUI testing, and using example from http://easytesting.org/swing/wiki/pmwiki.php?n=FEST-Swing.LaunchFromMain
I'm trying to use an SSL client/server example from: http://simplestcodings.blogspot.com.br/2010/08/secure-server-client-using-openssl-in-c.html to create a secure

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.