【问题标题】:How to fetch different html file in a single WebView in android studio如何在 android studio 的单个 WebView 中获取不同的 html 文件
【发布时间】:2017-07-23 21:57:08
【问题描述】:

我是一个初学者,我正在尝试为一本书制作一个应用程序,该书有 15 章,每章都有 25 个主题。在主要活动中,我想要 15 个带有 ch 的按钮。名称,当单击一个按钮时,它会转到另一个具有 25 个带有主题的按钮的活动,当单击一个主题时,它会从 assets 文件夹中获取一个 html 文件并将其显示在一个具有 webview 的新活动中。现在我的问题是,当在同一个活动上单击按钮时,我如何获取相应的 html 文件?或者我必须为每个主题使用差异活动。这将是非常冗长(超过 300 个)的活动。

【问题讨论】:

    标签: android html android-activity webview


    【解决方案1】:
        You should save the Web view calling method in a Util Class and load URL with corresponding to your Activity
    
        Ex: wv1.getSettings().setLoadsImagesAutomatically(true);
                    wv1.getSettings().setJavaScriptEnabled(true);
                    wv1.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                    wv1.loadUrl(url);
    
        And Then pass URL as String to your activity 
    eg. String url = ed1.getText().toString();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-04
      • 2015-04-03
      • 2012-03-17
      • 2015-04-02
      • 2017-12-21
      • 1970-01-01
      • 2018-01-18
      相关资源
      最近更新 更多