gpt4 book ai didi

安卓禁用 Activity

转载 作者:行者123 更新时间:2023-11-29 14:11:34 26 4
gpt4 key购买 nike

如何使 Activity 暂时不可触摸且不可聚焦?

最佳答案

您可以在需要时关闭所有监听器。我使用的另一种方法是使用透明的LinearLayout或RelativeLayout膨胀以覆盖整个屏幕一段时间。

public void coveredScreen(){
if(point_total>0){
parent = (RelativeLayout) findViewById(R.id.main_view); //whatever your layout is
loadedView = getLayoutInflater().inflate(R.layout.covered_screen, null); //the layout that contains something that fills parent.

parent.addView(loadedView);

updateHandler = new Handler();

updateHandler.postDelayed(coveredScreen, 2000); //opens layout for 2000 ms

// turns off listeners...
button1.setClickable(false);
button2.setClickable(false);

}

Runnable loadingScreen = new Runnable() {
public void run() {
// this turns on listeners and removes the inflated view
parent.removeView(loadedView);
button1.setClickable(true);
button2.setClickable(true);

// Call this method again every 3 seconds if desired or as long as wanted by uncommenting this handler
//updateHandler.postDelayed(this, 3000);
}
};

所以...只要你愿意就可以设置它,然后每次你想阻止用户在 Activity 中的任何操作时调用。

关于安卓禁用 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2643689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com