乳清我写下面的代码,网址是在默认浏览器中打开的,为什么它没有加载到我的应用程序中。
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webView);
myWebView.loadUrl("http://www.google.com");
答案 0 :(得分:1)
尝试在WebViewClient
上设置WebView
:
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
myWebView.loadUrl("http://www.google.com");
答案 1 :(得分:1)
也许您想要此解决方案:
#include <stdint.h>
#include <stdio.h>
int main (void)
{
uint8_t myarr[4]={0x11,0x12,0x33,0x1A};
char hexstr[4][2+1] = {0};
const char HEX [16] = "0123456789ABCDEF";
for(size_t i=0; i<4; i++)
{
hexstr[i][0] = HEX[ (myarr[i] & 0xF0) >> 4 ];
hexstr[i][1] = HEX[ (myarr[i] & 0x0F) ];
puts(hexstr[i]);
}
}
别忘了添加权限:
WebView webview = findViewById(R.id.webviewLW);
webview = new WebView(this);
webview.getSettings().setLoadsImagesAutomatically(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webviewLWComplience.setWebViewClient(new WebViewClient() {
@SuppressWarnings("deprecation")
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(MainActivity.this, description, Toast.LENGTH_SHORT).show();
}
@TargetApi(android.os.Build.VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {
// Redirect to deprecated method, so you can use it in all SDK versions
onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
}
});
webviewLWComplience.loadUrl(CONSTANTS.HOST_URL);
setContentView(webviewLWComplience);