【问题标题】:Dropdown (Select tag, Combobox) not working in GeckoView implementation下拉菜单(选择标签、组合框)在 GeckoView 实现中不起作用
【发布时间】:2020-02-28 10:35:25
【问题描述】:

我正在 Android 应用程序中实现 Geckoview 实例。一切看起来都正常工作,Geckoview 能够加载 URL。 我的问题是,如果网站有下拉菜单(选择标签、组合框),当我单击箭头时,选项不会出现。

我已尝试使用存储库的不同版本和渠道(夜间、发布、测试版),但我仍然遇到同样的问题。

我已经在不同的设备和版本的 android 上进行过尝试。

当我使用使用 Geckoview(参考浏览器,Firefox 预览)的浏览器时,“下拉菜单”工作得很好,所以我认为这是我的 Geckoview 实现中的配置问题。

GeckoView geckoview;
GeckoSession session;
GeckoRuntime runtime;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    geckoview = findViewById(R.id.geckoviewer);
    session = new GeckoSession();

    session.getSettings().setAllowJavascript(true);
    session.getSettings().setDisplayMode(GeckoSessionSettings.DISPLAY_MODE_FULLSCREEN);
    session.getSettings().setUserAgentMode(GeckoSessionSettings.USER_AGENT_MODE_MOBILE);

    GeckoRuntimeSettings.Builder builder = new GeckoRuntimeSettings.Builder()
            .javaScriptEnabled(true)

            .consoleOutput(true);

    runtime = GeckoRuntime.create(this, builder.build());

    session.open(runtime);

【问题讨论】:

    标签: gecko geckoview


    【解决方案1】:

    原因是 GeckoView 没有为此提供默认实现。您需要实现PromptDelegate(在本例中为onChoicePrompt())。

    查看 API 文档: https://mozilla.github.io/geckoview/javadoc/mozilla-central/org/mozilla/geckoview/GeckoSession.PromptDelegate.html

    参考浏览器和 Firefox Preview 正在使用 Mozilla 的“Android 组件”项目中的实现。feature-prompts 组件实现了所有这些提示: https://github.com/mozilla-mobile/android-components/tree/master/components/feature/prompts

    “GeckoView 示例应用”使用了另一种实现,您可以在此处找到该代码: https://searchfox.org/mozilla-central/source/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/BasicGeckoViewPrompt.java

    【讨论】:

    • 谢谢。我已经基于您共享的 Gecko View Example App 实现了甚至更简单的 PromptDelegate。它正在工作。
    • 这个例子的一些实际解决方案会很好 - 它在网络上的任何地方都找不到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2016-07-03
    • 1970-01-01
    • 2018-02-22
    相关资源
    最近更新 更多