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
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Got this from here http://stackoverflow.com/a/10721034

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

B4X:
#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

tufanv

Expert
Licensed User
Longtime User
TY !
I will try it out
Got this from here http://stackoverflow.com/a/10721034

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

B4X:
#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

tufanv

Expert
Licensed User
Longtime User
Two other options:
1. Disable all views:
B4X:
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 :

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

for disable all views. Thanks !
 
Upvote 0
Top