Android Question Setting all activity.enabled to false

tufanv

Expert
Licensed User
Longtime User
Hello

In b4i we can use page1.rootpanel.userinteractionenabled=false to disable all views for user interaction. Is there a similar way in b4a ? I do not want to use pane1.enabled=false becuase i have too many panels. I just need to disable the whole activity for interaction

TY
 
Got this from here http://stackoverflow.com/a/10721034

Code: Copy
    Dim java As JavaObject
    java.InitializeContext
    java.RunMethod("disableactivity",Null)
'or to enable activity
java.RunMethod("enableactivity",Null)

Code: Copy
#if java
import android.view.WindowManager;

public void disableactivity(){
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

}

public void enableactivity() {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}
#end if
 
Upvote 0
TY !
I will try it out
Got this from here http://stackoverflow.com/a/10721034

Code: Copy
    Dim java As JavaObject
    java.InitializeContext
    java.RunMethod("disableactivity",Null)
'or to enable activity
java.RunMethod("enableactivity",Null)

Code: Copy
#if java
import android.view.WindowManager;

public void disableactivity(){
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

}

public void enableactivity() {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}
#end if
 
Upvote 0
Two other options:
1. Disable all views:
Code: Copy
For Each v As View In Activity.GetAllViewsRecursively
v.Enabled = True
Next
2. Bring a transparent panel to the front and handle its touch event or click event.

Yes this also work perfect but the right one is :

Code: Copy
For Each v As View In Activity.GetAllViewsRecursive
v.Enabled = false
Next

for disable all views. Thanks !
 
Upvote 0
Back
Top