Merge "Fix use of WebView.loadData() to avoid passing invalid encoding"

This commit is contained in:
Steve Block
2011-10-17 09:00:28 -07:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ public class Focus1 extends Activity {
WebView webView = (WebView) findViewById(R.id.rssWebView);
webView.loadData(
"<html><body>Can I focus?<br /><a href=\"#\">No I cannot!</a>.</body></html>",
"text/html", "utf-8");
"text/html", null);
ListView listView = (ListView) findViewById(R.id.rssListView);
listView.setAdapter(new ArrayAdapter<String>(this,

View File

@@ -35,38 +35,37 @@ public class WebView1 extends Activity {
setContentView(R.layout.webview_1);
final String mimeType = "text/html";
final String encoding = "utf-8";
WebView wv;
wv = (WebView) findViewById(R.id.wv1);
wv.loadData("<a href='x'>Hello World! - 1</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 1</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv2);
wv.loadData("<a href='x'>Hello World! - 2</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 2</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv3);
wv.loadData("<a href='x'>Hello World! - 3</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 3</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv4);
wv.loadData("<a href='x'>Hello World! - 4</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 4</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv5);
wv.loadData("<a href='x'>Hello World! - 5</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 5</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv6);
wv.loadData("<a href='x'>Hello World! - 6</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 6</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv7);
wv.loadData("<a href='x'>Hello World! - 7</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 7</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv8);
wv.loadData("<a href='x'>Hello World! - 8</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 8</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv9);
wv.loadData("<a href='x'>Hello World! - 9</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 9</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv10);
wv.loadData("<a href='x'>Hello World! - 10</a>", mimeType, encoding);
wv.loadData("<a href='x'>Hello World! - 10</a>", mimeType, null);
}
}

View File

@@ -95,12 +95,12 @@ public class MyRssReader5 extends Activity implements OnItemSelectedListener {
mLogger.warning("MyRssReader5.onItemSelected() couldn't get the content" +
"from the cursor " + e.getMessage());
}
mWebView.loadData(content, "text/html", "utf-8");
mWebView.loadData(content, "text/html", null);
}
//END_INCLUDE(5_4)
public void onNothingSelected(AdapterView parent){
mWebView.loadData("<html><body><p>No selection chosen</p></body></html>", "text/html", "utf-8");
mWebView.loadData("<html><body><p>No selection chosen</p></body></html>", "text/html", null);
}
// Store our state before we are potentially bumped from memory.