Динамически изменяемое значение HTML из Android - PullRequest
1 голос
/ 05 сентября 2011

Я использую WebView to load HTML file, который хранится в каталоге assets/www.

HTML-файл:

<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
 </head>
 <body>
 <script>

new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 6,
  interval: 6000,
  title: '@palafo',
    width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#ad0000',
      color: '#ffffff'
    },
    tweets: {
      background: '#ffffff',
      color: '#444444',
      links: '#ad0000'
    }
  },
  features: {
    scrollbar: true,
    loop: false,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    behavior: 'all'
  }
}).render().setUser('CareerBuilder').start();

</script> 
 </body>
</html>

Этот HTML-файл загружает страницу Twitter в моем веб-просмотре, используя.

webview.loadUrl("file:///android_asset/www/twitter.html");

Теперь я хочу изменить имя пользователя динамически, здесь в этом случае имя пользователя - CareerBuilder, теперь я хочу изменить это имя динамически, когда я нажимаю в моем ListView, т.е. CareerBuilder, на x или y и т. Д.,.

Как это сделать?

Спасибо

1 Ответ

1 голос
/ 05 сентября 2011

У меня такое же приложение, которое я использовал ниже код .....

InputStream is = getAssets().open("introduction.html");
            int size = is.available();

            // Read the entire asset into a local byte buffer.
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();

            // Convert the buffer into a string.
            str = new String(buffer);

            str = str.replace("XXXX", days);

Изменение в файле HTML ....

<html>
    <head>
        <meta name="viewport" content="width=300, user-scalable=no">
        <title>Intro</title>
        <style type="text/css">
            body {
                padding:0;
                margin:0;
                font-family: Helvetica;
                font-size: 25px;
                background-color:#000000;
                color:#A4C639;
            }
            td {
                text-align: center;
}
        </style>
    </head>
    <body style="width: 300px;">
        <table width="100%" style="margin-top: 5px;">
            <tr>
                <td>
                    <b>Welcome to the Voting Card<font size="1">tm</font> App, only</b>
                    <br/>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="font-size:130px;font-weight:bold;">XXXX</span>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="font-size:18px;">
                    Days Until the Nov. 6th, 2012 Presidential election.
                    <br/><br/>
                    Check back periodically to see what else the U.S. Congress in Washington, D.C.
                    is voting on and stay in contact with your elected officials.
                    <br/><br/>
                    For more information about VOTING CARDtm and its upcoming features visit us at
                    <br/><br/>
                    www.capitolgamescience.com
                    <br/><br/>
                    or email us at
                    <br/><br/>
                    votingcard@capitolgamescience.com
                    <br/><br/>
                    Thank you for using our app,
                    <br/><br/>
                    Capitol Game Science Media, LLC
                    <br/>
                    <br/><br/>
                    We respect your privacy and abide by applicable U.S. privacy laws.
                    None of your personal information will be retained or recorded.
                    Your emails and web browsing will be conducted from your device.
                    </span>
                </td>
            </tr>
        </table>
    </body>
</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...