我将从Android应用中保存的数据插入到html输入中时遇到问题。网站被加载到WebView组件中,所以我可以在我的应用程序中访问我的网站,但我仍然无法将保存的数据(从以前的活动)插入到html文本输入中...
我找到了一些代码 - webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'");
并尝试使用此链接中的代码 - https://stackoverflow.com/a/12450427/1196540但这些代码对我不起作用...
任何人都可以提出建议或帮助解决我的问题吗?
UPD 这是我的网络形式:
<form method="post" action="">
<input name="pass" id="pass_id" type="password" autocomplete="off" value="" class="keyboardInput" onkeyup="$('#warn2').show();"/>
UPD 2
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser_screen);
Intent intent = getIntent();
CLIENT_ID = intent.getExtras().getString("CLIENT_ID");
lang = intent.getExtras().getString("LANGUAGE");
CLIENT_PWD = intent.getExtras().getString("PASSWORD");
if (lang.equals("English"))
url = link.getEng();
else if (lang.equals("Russian"))
url = link.getRussian();
else if (lang.equals("Dutch(German)"))
url = link.getDeutch();
else if (lang.equals("French"))
url = link.getFrance();
else if (lang.equals("Italian"))
url = link.getItalian();
else if (lang.equals("Spanish"))
url = link.getSpanish();
//go to the website
WebView webview = new WebView(this);
setContentView(webview);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
data = "client_id=" + CLIENT_ID;
webview.postUrl(url, EncodingUtils.getBytes(data, "base64"));
//insert pass
//webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'");
webview.loadUrl("javascript:document.getElementById('pass_id').focus()");
}