简体   繁体   English

弹出对话框后控制底层元素

[英]Control underlying elements after popping up a dialog

I am popping up a dialog from an Application context by calling an intent which has a transparent theme.( Similar to what is mentioned here.) The pop is a read only.The issue is that when the pop up is shown there is a current activity going on in the background. 我正在通过调用具有透明主题的Intent从Application上下文中弹出一个对话框。( 类似于此处提到的内容。)pop是只读的。问题是当显示弹出窗口时,当前活动在后台进行。 I need to be able to access the background activity too while the popup is dispalyed. 显示弹出窗口时,我还需要能够访问后台活动。 I have added the following two lines but it still is not possible for me to control the underlying activity: 我添加了以下两行,但是我仍然无法控制基础活动:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

What am I doing wrong? 我究竟做错了什么?

you must open the dialog in a thread, you haven't explained much about what you want to do in background ,but for making a thread do this: create a new class with name:thread1 then write down these there: 您必须在线程中打开对话框,您没有对要在后台执行的操作进行过多解释,但是要使线程执行此操作,请执行以下操作:创建一个名称为:thread1的新类,然后在其中写下这些内容:

public class thread1 extends Thread {
MainActivity activity;
public  thread1(MainActivity m){
activity=m;
ProgressDialog pd;
//other code maybe for specification
pd=ProgressDialog.show(activity,"", "wait for background activity");
}
@Override
public void run(){
         //you code working in background here like:
         activity.sucess=0;
         while (activity.sucess==0){
        android.os.SystemClock.sleep(300);  
    }
    pd.dismiss();
}
}

whenever you want to open this pb you should write this, 每当您要打开此PB时,都应该写下来

thread1 t1=new thread1(this);
t1.start();

and when ever your work is done and you want to close the pb, you must set sucess=1 then the thread will be killed. 当您完成工作并想要关闭pb时,必须将sucess = 1设置为该线程将被杀死。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM