Trying to activate android back button from webview within a fragment -


i'm trying button work here webview within fragment. code not compile can tell me i'm doing wrong?

i'm getting "webview accessed within inner class needs final" error.

also i'm getting "cannot resolve symbol handler" error.

package info.androidhive.slidingmenu;

import android.app.fragment; import android.os.bundle; import android.view.keyevent; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient;  public class pagesfragment extends fragment {      public pagesfragment(){}        @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {          view rootview = inflater.inflate(r.layout.fragment_pages, container, false);          webview webview = (webview) rootview.findviewbyid(r.id.webviewpages);         webview.getsettings().setjavascriptenabled(true);          webview.setwebviewclient(new webviewclient());         webview.loadurl("http://www.google.com");         websettings websettings = webview.getsettings();         websettings.setjavascriptenabled(true);          webview.setonkeylistener(new view.onkeylistener(){              public boolean onkey(view v, int keycode, keyevent event) {                 if ((keycode == keyevent.keycode_back) && webview.cangoback()) {                     handler.sendemptymessage(1);                     return true;                 }                 return false;             }          });          return rootview;       }    } 

webview accessed within inner class needs final

webview variable needs final accessible inner class. declare it:

final webview webview = (webview) rootview.findviewbyid(r.id.webviewpages); 

cannot resolve symbol handler

there no symbol called handler in current scope used from:

handler.sendemptymessage(1); 

you need declare symbol.

if ask such questions, guess following tutorial. check tutorial again, missed something.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -