【问题标题】:how to insert an android webview programatically next to a textview?如何以编程方式在 textview 旁边插入 android webview?
【发布时间】:2022-01-21 23:23:58
【问题描述】:

我需要在具有唯一 ID 的 textview 旁边插入我的 Webview,在 java 中是否有类似 javascript 的 Node.insertBefore(); 的东西。 我尝试了以下方法:例如:

    LinearLayout layout = findViewById(R.id.linear_view);
    webview = new WebView(this);
    webview.setId(10);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebContentsDebuggingEnabled(true);
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl("https://www.google.co.in/");
    layout.addView(webview);

但在我的情况下,我无法获取布局 id,我只会获取 textview id。

【问题讨论】:

    标签: java android android-studio webview mobile-application


    【解决方案1】:

    试试这个;

    layout.addView(webView, layout.getChildCount())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 2017-08-23
      相关资源
      最近更新 更多