Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在 Eclipse 中为 Android 编写一个应用程序。该应用程序不断与 Web 服务器中的内容进行通信。在服务器中,我有一个带有另一个按钮的 html 文件。我希望当我按下我的 Android 应用程序中的按钮时,html 文件中的按钮是自动点击的.. 是否可能。请建议..
我通过以下代码(jquery)看到了这一点:
$(".press").trigger('click');
实现了 html 按钮的自动点击,但我如何从 android 中的 java 中做到这一点?
谢谢
只需使用 javascript:
yourButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { yourWebView.loadUrl("javascript:clickHtmlButton()"); } });
javascript:
function clickHtmlButton(){ $(".press").click(); }