0
我想填充本地存儲的簡單html表單,其中包含意圖傳遞的數據並在webview中顯示我的html表單以便打印它。如何將數據插入到本地html表單並在webview上顯示
我驗證了意圖數據傳遞給我的活動,但是當我嘗試加載數據時,我得到空字段。我做了以下事情:
Intent intent = getIntent();
String name = intent.getStringExtra("ServiceName");
InputStream is = null;
try {
is = getAssets().open("form.html");
} catch (IOException e) {
e.printStackTrace();
}
int size = 0;
try {
size = is.available();
} catch (IOException e) {
e.printStackTrace();
}
byte[] buffer = new byte[size];
try {
is.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
String str = new String(buffer);
str = str.replace("textarea4", name);
WebView wv = (WebView) findViewById(R.id.webView);
wv.loadData(str, "text/html; charset=utf-8", "UTF-8");
我在這裏失蹤了什麼?
'海峽= str.replace( 「textarea4」,名);'。我們當然不知道這是否有效。你應該顯示完整的輸入。 – greenapps