我创建了一个WebView布局,用于访问特定网站,但是当手机没有网络连接或页面超时时,编辑或创建自定义" 网页不可用 "资源会很有用.我知道这是可能的,因为如果您在手机处于飞行模式时打开应用程序" Wikidroid ",则会收到" 文章不可用 "错误页面而不是标准Android" 网页不可用 "错误页面.
我在互联网上搜索高低,并没有提出任何解决此请求的在线资源.任何和所有的帮助非常感谢.提前致谢.
有没有办法在WebView中设置超时值?如果网址响应太慢,我希望WebView有时间.
我试图将JQuery文件包含在资产/脚本和Internet上,但是警告对话框没有显示.我得到了日志输出并使其成为output.html,它在Windows中工作(太奇怪了!).WebView有什么问题?
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView);
final String s = "<html><head>" +
"<link href=\"css/my.css\" type=\"text/css\" rel=\"stylesheet\" />" +
"<script src=\"scripts/jquery-1.6.2.min.js\" rel=\"stylesheet\" type=\"text/javascript\"></script>" +
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js\" type=\"text/javascript\"></script>" +
"<script>" +
"$(document).ready(function(){ alert('hello'); });" +
"</script>" +
"</head><body><div>All I hear is raindrops." +
"Falling on the rooftop. Oh baby tell me why you have to go. " +
"Cause this pain I feel you won't go away. And today, " +
"I'm officially missing you.</div></body></html>"; …Run Code Online (Sandbox Code Playgroud) 背景:
我通过我的应用程序获取cookie并通过向http发出请求在内部使用它们.用户可以在任何给定时间切换到webview,在这种情况下,我将cookie同步/注入到webView.
使用CookieSyncManager将Cookie同步到webview的代码:
CookieSyncManager.createInstance(a);
CookieManager cm = CookieManager.getInstance();
cm.setCookie(domain, cookieName + "=" + cookieValue);
CookieSyncManager.getInstance().sync();
Run Code Online (Sandbox Code Playgroud)
这适用于除 API 15+(Android 4.0,Ice Cream Sandwich)之外的所有 API级别.该CookieManager API不会被弃用.
是什么导致了这个问题,有没有解决方法?
cookies android android-webview android-4.0-ice-cream-sandwich
我想显示图像(包括滚动和缩放功能).另外,我需要动态地为图像添加一些叠加层.叠加层与图像中的内容有关系.
换句话说:我想用一些标记来实现Map,但我提供了自己的地图材质.
我的主要问题是:我怎么能这样做?
到目前为止我尝试过的
问题
我的问题有一个简单的解决方案或方法吗?
在Android中运行时添加和移动视图的正确方法是什么?(通常,我会使用基本布局并使用保证金 - 这是最佳做法吗?)
请有人指出我正确的方向.
闵.API等级:10
我正在从字符串加载数据,并且在我第一次向下滚动webview时闪烁几次.
这是我加载数据的代码:
webview.loadDataWithBaseURL(null, message.getmContent(), "text/html", "UTF-8", null);
Run Code Online (Sandbox Code Playgroud)
和xml:
<WebView
android:id="@+id/web_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer"
android:layout_below="@id/message_title"
android:layout_margin="4dp"
/>
Run Code Online (Sandbox Code Playgroud) 我想在加载WebView后对WebView进行快照.但是,返回的位图始终为null,因为即使我使用了渲染也未完成加载onPageFinished.我在互联网上搜索,人们建议使用WebView.PictureListener,但在API 12中不推荐使用此功能.
一些代码
public class MainActivity extends Activity {
private WebView mButterflyWebView;
/**
* Gets html content from the assets folder.
*/
private String getHtmlFromAsset() {
InputStream is;
StringBuilder builder = new StringBuilder();
String htmlString = null;
try {
is = getAssets().open(getString(R.string.butterfly_html));
if (is != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
htmlString = builder.toString();
}
} catch (IOException …Run Code Online (Sandbox Code Playgroud) 我试图在Android应用程序Web视图中加载该网站.
网站加载没有图像,网站上的所有图像都没有加载可能是什么问题.
onCreate的代码如下所示.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
String url = getResources().getString(R.string.web_url);
web = (WebView) findViewById(R.id.webview01);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setUseWideViewPort(true);
web.loadUrl(url);
}
Run Code Online (Sandbox Code Playgroud)
还有一点需要注意,当我使用web.getSettings()将javascript设置为false时.setJavaScriptEnabled(false); 图像加载时发出警告,应启用javascript以正确运行网站.
这个网站受CloudFlare保护,这可能是因为这个原因导致图像没有加载到android网页视图中吗?
我正在开发一个使用WebView来呈现自定义html的应用程序.但是当我调用
loadDAtaWithBaseURL(URL, "<html><h1>TEST</h1></html>", "text/html; charset=utf-8;", "utf-8", null);
它时,它会在Genymotion模拟器上显示html本身(未呈现一个).在我的HTC-one上,它与渲染的html一起正常工作.每个结果显示为附件.

有没有人有同样的问题或解决方案?谢谢.
我需要将数据发布到Webview.
我从以下代码中找到了一些链接:
WebView webview = new WebView(this);
setContentView(webview);
String url = "http://www.example.com";
String postData = username=my_username&password=my_password";
webview.postUrl(url",EncodingUtils.getBytes(postData, "BASE64"));
Run Code Online (Sandbox Code Playgroud)
但是在我的android工作室中我看到EncodingUtils已被弃用
任何人都可以帮我解决EncodingUtils将数据发布到Android WebView的替代方案吗?
android ×10
android-webview ×10
android-4.0-ice-cream-sandwich ×1
cookies ×1
html ×1
http-post ×1
jquery ×1
snapshot ×1