Android incompatible types error -


upon compiling i'm getting error:

error: incompatible types: <anonymous webviewclient> cannot converted context 

the error coming line:

progress = progressdialog.show(this, "", "loading...", true); 

this meant class context, think it's this, don't understand context or how fix it.

mainactivity.java

public class mainactivity extends appcompatactivity         implements navigationview.onnavigationitemselectedlistener {      progressdialog progress;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          webview webview = (webview) findviewbyid(r.id.webview);         webview.getsettings().setjavascriptenabled(true);          webview.setwebviewclient(new webviewclient() {             drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);             @override             public boolean shouldoverrideurlloading(webview webview, string urlnewstring) {                 webview.loadurl("http://www.google.com");                 return true;             }             @override             public void onpagestarted(webview webview, string url, bitmap facicon) {                 progress = progressdialog.show(this, "", "loading...", true); // offending line             }             @override             public void onpagefinished(webview webview, string url) {                 drawer.closedrawer(gravitycompat.start);                 progress.dismiss();             }             public void onreceivederror(webview webview, int errorcode, string description, string failingurl) {                 webview.loadurl("file:///android_asset/www/error.html");                 drawer.opendrawer(gravitycompat.start);                 progress.dismiss();             }         });         .         .     }     .     . } 

change

progress = progressdialog.show(this, "", "loading...", true); 

to

progress = progressdialog.show(mainactivity.this, "", "loading...", true); 

that line of code inside onpagestarted method of anonymous class. this refers anonymous class, not current activity context.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -