Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从html到android获取输入类型值_Java_Android_Html_Input_Webview - Fatal编程技术网

Java 从html到android获取输入类型值

Java 从html到android获取输入类型值,java,android,html,input,webview,Java,Android,Html,Input,Webview,我想做一个网络视图计算器。让我有一个基于HTML的计算器UI <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Calculator</title> <link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet'

我想做一个网络视图计算器。让我有一个基于HTML的计算器UI

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calculator</title>
    <link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>

</head>
<body>
<form action="" name="calc">
    <input type="text" name="screen" disabled> <br>
    <hr>
    <input type="button" value="&radic;" onclick="calc.screen.value = Math.sqrt(calc.screen.value);">
    <input type="button" value="CE" onclick="calc.screen.value = ''">
    <input type="button" value="C" onclick="calc.screen.value = ''">
    <input type="button" value="&larr;" onclick="calc.screen.value = calc.screen.value.slice(0,-1);"> <br>

    <input type="button" value="7">
    <input type="button" value="8">
    <input type="button" value="9">
    <input type="button" value="+">

    <br>

    <input type="button" value="4">
    <input type="button" value="5">
    <input type="button" value="6">
    <input type="button" value="-">

    <br>

    <input type="button" value="1">
    <input type="button" value="2">
    <input type="button" value="3">
    <input type="button" value="*">

    <br>

    <input type="button" value="0">
    <input type="button" value=".">
    <input type="button" value="=">
    <input type="button" value="/"> <br>
</form>
</body>
</html>

计算器







现在,我想从一个按钮中获取值,然后在android java类中进行计算。之后,最终结果将以HTML显示


如何将输入类型的值从HTML获取到android并传回?

您需要使用android JavaScriptInterface类从HTML输入字段获取数据

JavaScriptInterface具有processFormData()方法以字符串形式返回数据

然后,您可以根据需要处理这些数据


您发现一些

您需要使用Android JavaScriptInterface类从html输入字段获取数据

JavaScriptInterface具有processFormData()方法以字符串形式返回数据

然后,您可以根据需要处理这些数据

你找到了一些