[英]Using loadUrl to get all select options in a drop down box
I'm trying to store all values from a drop down box into variables within my android application. 我正在尝试将下拉框中的所有值存储到我的android应用程序中的变量中。 I'm trying to get all options from the below into strings in my app;
我正在尝试将以下所有选项放入应用程序的字符串中;
<select name="cardId" id="select_card_no" onfocus="null" onchange="null">
<option value="">Choose card number</option>
<option value="010607655930" >010607655930</option>
<option value="050538806749" >050538806749</option>
<option value="054100790989" >054100790989</option>
</select>
I've been using code like this to intially log through parts of the site; 我一直在使用这样的代码来初始登录网站的各个部分;
public void onPageFinished(WebView view, String url) {
if(url == "https://oyster.tfl.gov.uk/oyster/entry.do"){
String ausername = "abcde";
String apassword = "12345";
view.loadUrl("javascript:document.getElementsByName('j_username')[0].value = '"+ausername+"'");
view.loadUrl("javascript:document.getElementsByName('j_password')[0].value = '"+apassword+"'");
view.loadUrl("javascript:document.forms[0].submit()");
}
But was wondering how you could possibly get text back from the current Webview state, can you somehow convert loadUrl into a string; 但是想知道如何从当前Webview状态中获取文本,是否可以将loadUrl转换为字符串?
String ddl = view.loadUrl("javascript:document.getElementById('select_card_no')");
Possible duplicate question. 可能重复的问题。 You may want to check out the answer to this one:
您可能要查看此答案:
android - get Text out of webview android-从Webview中获取文本
Also, there might be an overall better solution than using this webview approach you're trying. 此外,可能有比使用您尝试使用的Webview方法更好的整体解决方案。 That url does have a developer api: android - get Text out of webview
该网址确实具有开发人员API: android-从Webview中获取文本
You may want to try and see if you can get waht you need out of that. 您可能想尝试一下,看看能否从中得到满足。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.