Advertisement
Ankhwatcher

Handle Back Button Press For WebView In Fragment

Sep 16th, 2012
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.29 KB | None | 0 0
  1. /*In Activity*/
  2. @Override
  3.     public void onBackPressed() {
  4.  
  5.         if (!clientFragment.onBackPressed()) {
  6.             super.onBackPressed();
  7.         }
  8.     }
  9. /*In Fragment*/
  10. public boolean onBackPressed() {
  11.         if (webView.canGoBack()) {
  12.             webView.goBack();
  13.             return true;
  14.         } else {
  15.             return false;
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement