我需要编程填开了一个web视图里面的网页文本字段。如何? [英] I need to fill text field programatically in a web page opened inside a WebView. How To?

查看:137
本文介绍了我需要编程填开了一个web视图里面的网页文本字段。如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个web视图,并开辟了一个网页,它包含一种形式。我需要以编程方式填写该表格(需要得到一些数据形式SQLite数据库并填写)。

I have created a WebView and opened up a web page in it that contains a form. I need to fill that form programmatically (need to get some data form sqlite database and fill it).

我怎么能做到这一点?任何人都可以请帮我。

how i can do that ? can anyone please help me out.

编辑:网页是一个注册表单,我没有自己的网页..我不能添加Java脚本到该页面

EDIT : the web page is a sign-up form and i do not own that web page.. i cannot add java script into that page.

推荐答案

我会使用JavaScript在这种情况下。

I would use javascript in this situation.

下面是如何。让你的WebView的JavaScript功能。

Here is how. Make your webview javascript-enabled.

Java的code在你的WebView活动

Java code in your webview activity

webview.loadUrl("javascript: fillUpForm(inputId,inputValue)");

在JavaScript的HTML文件

javascript in your html file

function fillUpForm(id,value)
{
  document.findElementById(id).value=value;
}

坦率地说,我在JavaScript方面的专家。但是,这应该给你的出发点。

Frankly, I am no expert in javascript. But this should give you starting point.

好了,你的情况,

我会尝试这种

view.loadUrl("javascript:(function(){document.getElementById('trop').value='some value';})()");

这篇关于我需要编程填开了一个web视图里面的网页文本字段。如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆