【发布时间】:2012-06-26 15:36:23
【问题描述】:
在加载带有锚链接的 html 内容时,我在 webview 中遇到了一些奇怪的问题。
以下代码非常适合锚标记,但只有一次。
第二次按下锚标签时,它不起作用。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mywebview);
String html = "<html><body><p><a href='#C4'>See also Chapter 4</a></p><p><h2>Chapter 1</h2><p>This chapter explains ba bla bla</p><h2>Chapter 2</h2><p>This chapter explains ba bla bla</p><h2>Chapter 3</h2><p>This chapter explains ba bla bla</p><h2><a name='C4'>Chapter 4</a></h2><p>This chapter explains ba bla bla</p><h2>Chapter 5</h2><p>This chapter explains ba bla bla</p><h2>Chapter 6</h2><p>This chapter explains ba bla bla</p><h2>Chapter 7</h2><p>This chapter explains ba bla bla</p><h2>Chapter 8</h2><p>This chapter explains ba bla bla</p><h2>Chapter 9</h2><p>This chapter explains ba bla bla</p></body></html>";
String mime = "text/html";
String encoding = "utf-8";
WebView myWebView = (WebView)this.findViewById(R.id.webView1);
myWebView.loadDataWithBaseURL(null, html, mime, encoding, null);
}
我尝试了this 链接,但对我不起作用。
更新:
我的代码在各种设备上的测试结果。
工作
1. 三星 S Plus --> 2.3.4
2. 三星 Galaxy Y --> 2.3.6
3. 三星 Galaxy Tab --> 2.3.3
4. 摩托罗拉 Xoom --> 3.2
不工作
1. LG 擎天柱 --> 2.2
2. DELL XCD35(ZTE Blade) --> 2.2
3. HTC WildFire --> 2.2.1
这是操作系统问题还是其他问题?有什么解决办法吗??
【问题讨论】:
-
所有@DownVoters 你能解释下投票的原因吗?
标签: android html android-webview