本文介绍了onPageFinished()从来没有所谓的(web视图)!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给敬酒时的WebView是完全加载。但是,敬酒从不露面,我不知道why..here是我的code:
公共类WebViewSignUp延伸活动{
的WebView mWebView;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.webviewsignup);
mWebView =(web视图)findViewById(R.id.webview);
mWebView.getSettings()setJavaScriptEnabled(真)。
((TextView中)findViewById(R.id.home))。setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
完();
}
});
mWebView.setWebViewClient(新WebViewClient(){
@覆盖
公共无效onPageFinished(web视图查看,字符串URL){
super.onPageFinished(mWebView,URL);
Toast.makeText(getApplicationContext(),完成!,Toast.LENGTH_SHORT).show();
}
});
mWebView.loadUrl(http://pabebbe.com/m/register);
mWebView.setWebViewClient(新WebViewClient(){
公共无效onReceivedError(web视图来看,INT错误code,字符串描述,字符串failingUrl){
Toast.makeText(getApplicationContext(),哦,不!+描述,Toast.LENGTH_SHORT).show();
}
});
}
}
解决方案
要在第二个电话 setWebViewClient()
被覆盖的第一个。
创建了 WebViewClient
既覆盖在同一个类只有一个实例,并调用 setWebViewClient
只有一次。然后加载web视图:
mWebView.setWebViewClient(新WebViewClient(){
@覆盖
公共无效onPageFinished(web视图查看,字符串URL){
super.onPageFinished(mWebView,URL);
Toast.makeText(getApplicationContext(),完成!,Toast.LENGTH_SHORT).show();
}
@覆盖
公共无效onReceivedError(web视图来看,INT错误code,字符串描述,字符串failingUrl){
Toast.makeText(getApplicationContext(),哦,不!+描述,Toast.LENGTH_SHORT).show();
}
});
mWebView.loadUrl(http://pabebbe.com/m/register);
I want to show a toast when the webview is totally loaded. But the toast never show up, i don't know why..here is my code:
public class WebViewSignUp extends Activity{
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webviewsignup);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
((TextView)findViewById(R.id.home)).setOnClickListener(new OnClickListener(){
public void onClick(View v) {
finish();
}
});
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(mWebView, url);
Toast.makeText(getApplicationContext(), "Done!", Toast.LENGTH_SHORT).show();
}
});
mWebView.loadUrl("http://pabebbe.com/m/register");
mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(getApplicationContext(), "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
}
}
解决方案
The second call to setWebViewClient()
is overwriting the first.
Create only a single instance of WebViewClient
with both overrides in the same class, and call setWebViewClient
only once. Then load the Webview:
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(mWebView, url);
Toast.makeText(getApplicationContext(), "Done!", Toast.LENGTH_SHORT).show();
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(getApplicationContext(), "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
mWebView.loadUrl("http://pabebbe.com/m/register");
这篇关于onPageFinished()从来没有所谓的(web视图)!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!