android webview and loadData, can i get the back button to return to generated content?
I have an android webview
that displays generated content with loadDataWithBaseURL. Looks great. However, if i follow a link and then hit the back button I get a blank page where I'd like to see my generated content.
does开发者_运维技巧 anyone know how I can use the back button to return to my generated content?
Try this:
mWebView.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
if(mWebView.canGoBack() == true){
mWebView.goBack();
return true;
} else
return false;
}
return false;
}
});
精彩评论