當前位置:
首頁 >
Android解决button反复点击问题
發(fā)布時間:2025/6/15
42
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Android解决button反复点击问题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class BaseActivity extends Activity { protected boolean isDestroy;//防止反復點擊設置的標志。涉及到點擊打開其它Activity時。將該標志設置為false。在onResume事件中設置為trueprivate boolean clickable=true;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);isDestroy=false;requestWindowFeature(Window.FEATURE_NO_TITLE);setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);}@Overrideprotected void onDestroy() {super.onDestroy();isDestroy=true;}@Overrideprotected void onResume() {super.onResume();//每次返回界面時,將點擊標志設置為可點擊clickable=true;}/*** 當前能否夠點擊* @return*/protected boolean isClickable(){return clickable;}/*** 鎖定點擊*/protected void lockClick(){clickable=false;}@Overridepublic void startActivityForResult(Intent intent, int requestCode, Bundle options) {if(isClickable()) {lockClick();super.startActivityForResult(intent, requestCode,options);}}
}
總結
以上是生活随笔為你收集整理的Android解决button反复点击问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《算法设计编程实验:大学程序设计课程与竞
- 下一篇: Android_SQLite_升级框架