public class BaseActivity extends Activity {
protected boolean isDestroy;
//防止反复点击设置的标志。涉及到点击打开其它Activity时。将该标志设置为false。在onResume事件中设置为true
private boolean clickable=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isDestroy=false;
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
protected void onDestroy() {
super.onDestroy();
isDestroy=true;
}
@Override
protected void onResume() {
super.onResume();
//每次返回界面时,将点击标志设置为可点击
clickable=true;
}
/**
* 当前能否够点击
* @return
*/
protected boolean isClickable(){
return clickable;
}
/**
* 锁定点击
*/
protected void lockClick(){
clickable=false;
}
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if(isClickable()) {
lockClick();
super.startActivityForResult(intent, requestCode,options);
}
}
}