How can I handle a user pressing the back button, whilst a ShowcaseView is showing? I want to be able to hide the ShowcaseView when they press back.
As linked from https://github.com/amlcurran/ShowcaseView/issues/376
ShowcaseView allows you to query if it is showing or not. So, if a user presses back and it is showing, simply hide it using Activity#onBackPressed()
:
@Override
public void onBackPressed() {
if (sv.isShowing()) {
sv.hide();
} else {
super.onBackPressed();
}
}
Try this :
@Override
public void onBackPressed() {
// in if condition check showcaseview is show or hide
if(isShowcaseViewShow==true) {
// here hide your showcase view
}
else{
// here perform back action if view already hide
super.onBackPressed();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.