Android解决button反复点击问题
生活随笔
收集整理的這篇文章主要介紹了
Android解决button反复点击问题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class BaseActivity extends Activity { protected boolean isDestroy;//防止反復(fù)點擊設(shè)置的標(biāo)志。涉及到點擊打開其它Activity時。將該標(biāo)志設(shè)置為false。在onResume事件中設(shè)置為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();//每次返回界面時,將點擊標(biāo)志設(shè)置為可點擊clickable=true;}/*** 當(dāng)前能否夠點擊* @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);}}
}
總結(jié)
以上是生活随笔為你收集整理的Android解决button反复点击问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《算法设计编程实验:大学程序设计课程与竞
- 下一篇: 为你的亚马逊S3 bucket加个安全盖