进度对话框关闭时,在屏幕上触摸 [英] Progress Dialog is closed when touch on screen

查看:195
本文介绍了进度对话框关闭时,在屏幕上触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在线程中使用进度对话框 在按钮点击的线程开始,但是当我触摸屏幕上的任何进度对话框关闭。

我怎样才能在屏幕上prevent /块触摸进度对话框不会关闭。

 私人无效ButtonClick(查看视图){

     BTN1 =(按钮)view.findViewById(R.id.btn1);
     btn1.setOnClickListener(新View.OnClickListener(){
            公共无效的onClick(视图v){
                     GetStudentData();
           }
     });
  }


  私人同步无效GetStudentData(){

        尝试 {
        //线程显示加载器
        新的Thread(){
            @覆盖
            公共无效的run(){
                活套prepare()。
                对话框= Msg.ShowProgressDialogBox(getActivity()
                        对话,
                        请稍候,我们获取学生数据...);
                Looper.loop();
            }
        }。开始();

        新的Thread(){

            @覆盖
            公共无效的run(){
                      字符串studentData =凯拉斯;
             }
        }

  }
 

更新

当我触摸屏幕上的进度对话框消失,但得到的所有数据

解决方案

 私人同步无效GetStudentData(){

    尝试 {
    //线程显示加载器
    新的Thread(){
        @覆盖
        公共无效的run(){
            活套prepare()。
            对话框= Msg.ShowProgressDialogBox(getActivity()
                    对话,
                    请稍候,我们获取学生数据...);
            dialog.setCanceledOnTouchOutside(getRetainInstance());
            Looper.loop();
        }
    }。开始();

    新的Thread(){

        @覆盖
        公共无效的run(){
                  字符串studentData =凯拉斯;
         }
    }
}
 

我曾用这条线的 dialog.setCanceledOnTouchOutside(getRetainInstance()); ,并在我的 Android设备的OS(4.0.1)也测试了在OS运行正常(2.6.3)

I'm used progress dialog in the thread On button click the the thread is start but when i touch anywhere on the screen the progress dialog is closed.

How can i prevent/block touch on screen the progress dialog does not closed.

  private void ButtonClick(View view) {

     btn1 = (Button) view.findViewById(R.id.btn1);
     btn1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                     GetStudentData();
           }
     });
  }


  private synchronized void GetStudentData() {

        try {
        // Thread to display loader
        new Thread() {
            @Override
            public void run() {
                Looper.prepare();
                dialog = Msg.ShowProgressDialogBox(getActivity(),
                        dialog,
                        "Please wait while we fetch the student data...");
                Looper.loop();
            }
        }.start();

        new Thread() {

            @Override
            public void run() {
                      String studentData="Kailas";
             }   
        }

  }

Updated

When i touch on the screen the progress dialog is disappear but get all data

解决方案

private synchronized void GetStudentData() {

    try {
    // Thread to display loader
    new Thread() {
        @Override
        public void run() {
            Looper.prepare();
            dialog = Msg.ShowProgressDialogBox(getActivity(),
                    dialog,
                    "Please wait while we fetch the student data...");
            dialog.setCanceledOnTouchOutside(getRetainInstance());
            Looper.loop();
        }
    }.start();

    new Thread() {

        @Override
        public void run() {
                  String studentData="Kailas";
         }   
    }
}

I Have used this line dialog.setCanceledOnTouchOutside(getRetainInstance()); and it worked fine in my android device OS(4.0.1) also tested on OS(2.6.3)

这篇关于进度对话框关闭时,在屏幕上触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆