简体   繁体   中英

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. 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:

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,

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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