简体   繁体   English

如何从android中的webview文本框中获取价值?

[英]How to get value from textbox of webview in android?

Hello I want to know that is there any way to get value from webview html element or not. 您好,我想知道是否有任何方法可以从webview html元素获取价值。 I did load page in webview as follows 我确实在webview加载页面如下

package example.samplewebview; 

import android.annotation.SuppressLint; 
import android.app.Activity; 
import android.os.Bundle; 
import android.webkit.WebView; 

public class MainActivity extends Activity {
    WebView wv;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        wv = (WebView) findViewById(R.id.webView1);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.loadUrl("http://www.google.com");
        wv.get
    }
} 

and with this google.com page is loaded in webview . 并通过此google.com页面加载到webview now i want to get value from that search textbox and store in database any help will be appreciate. 现在我想从该搜索textbox获取价值并将其存储在数据库中,将不胜感激。

Assuming you are not Google, but you do want to use your own website, which you can modify, I suggest that you place a javascript on your webpage, that calls a native method inside your Android app and just submitts the value from this textfield. 假设您不是Google,但是您确实想使用自己的网站(可以修改),建议您在网页上放置一个javascript,该javascript会在您的Android应用程序内调用本机方法,并仅从此文本字段提交值。

There is already a thread on that topic here: android - get Text out of webview 此处已经有关于该主题的主题: android-从webview中获取文本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM