0
ローカルに保存された単純なhtmlフォームを入力し、そのデータをインテントに渡してWebビューに表示して印刷します。ローカル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 = str.replace( "textarea4"、名);'。もちろんそれがうまくいくかどうかは分かりません。完全な入力を示す必要があります。 – greenapps