【问题标题】:add html code on button in android to open html page on browser?在android中的按钮上添加html代码以在浏览器上打开html页面?
【发布时间】:2014-07-10 22:52:29
【问题描述】:

我想在 android 应用程序的注册表单中的提交按钮上添加 HTML 代码。我希望当按下提交按钮时,该代码的输出布局会在应用程序中的 Web 浏览器中打开。

此代码包括一些文本、URL 和订阅按钮,供我的 android 应用程序客户端通过 Paypal 支付加入会员资格。

我是这个领域的新手,所以请告诉我解决方案。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
  <input type="hidden" name="cmd" value="_xclick-subscriptions">
  <input type="hidden" name="business" value="DriverGroupConnect@gmail.com">
  <input type="hidden" name="lc" value="AU">
  <input type="hidden" name="item_name" value="DGC Taxi Membership">
  <input type="hidden" name="no_note" value="1">
  <input type="hidden" name="src" value="1">
  <input type="hidden" name="currency_code" value="AUD">
  <input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHostedGuest">
  <table>
    <tr>
      <td>
        <input type="hidden" name="on0" value="Monthly Payment Option">Monthly Payment Option</td>
    </tr>
    <tr>
      <td>
        <select name="os0">
          <option value="DGC Taxi Membership">DGC Taxi Membership : $25.99 AUD - monthly</option>
        </select>
      </td>
    </tr>
  </table>
  <input type="hidden" name="currency_code" value="AUD">
  <input type="hidden" name="option_select0" value="DGC Taxi Membership">
  <input type="hidden" name="option_amount0" value="25.99">
  <input type="hidden" name="option_period0" value="M">
  <input type="hidden" name="option_frequency0" value="1">
  <input type="hidden" name="option_index" value="0">
  <input type="image" src="https://www.paypalobjects.com/en_AU/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
  <img alt="" border="0" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>

【问题讨论】:

    标签: javascript android jquery html paypal


    【解决方案1】:

    好的,先用一个WebView来加载网页。
    http://www.mkyong.com/android/android-webview-example/

    如果您的网页是本地网页,请将 html 文件保存在 Assets 文件夹中。 http://www.androidsnippets.com/webview-load-from-assets

    在 onclick 按钮中启动 webview 的示例 http://www.tutorialspoint.com/android/android_webview_layout.htm

    检查示例中的 res/layout/activity_main.xml,特别是 Button。

    <Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/urlField"
          android:layout_centerHorizontal="true"
          android:onClick="open" <!-- Java method to launch webview -->
          android:text="@string/browse" />
    

    【讨论】:

    • 先生,您告诉我的解决方案我已经使用了这个解决方案。我的应用程序中的网页视图页面已打开,但该视图上的链接给出错误...
    【解决方案2】:

    您可以使用WebView 打开浏览器并将 html 代码放在那里...通过 bundle 将所有必需的数据传递到 webview 并在那里使用它..

    传递数据:

    Intent intent = new Intent(MainActivity.this,webViewActivity.class);
    
            intent.putExtra("key", data);
                intent.putExtra("key", data);
                 ...
    
            startActivity(intent);
    

    获取数据:

    Bundle bundle = getIntent().getExtras();
    data= bundle.getString("key");
    

    【讨论】:

    • 妈妈想知道如何使用 Web 视图打开浏览器并将 html 代码放在那里......以及如何将所有必需的数据通过捆绑传递到 Web 视图并在那里使用它。 .
    • 我给了你一个样本来传递数据......请谷歌了解如何使用网络视图......这不是一项艰巨的任务......
    猜你喜欢
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-23
    相关资源
    最近更新 更多