2011-09-05 6 views
1

WebView to load HTML file을 사용하고 있습니다. assets/www 디렉토리에 저장되어 있습니다.안드로이드에서 동적으로 변경하는 HTML 값

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 파일을 사용하여 내 웹보기에 트위터 페이지를로드합니다.

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

지금 내가이 경우 아이디 여기에 동적으로 사용자 이름을 변경 싶어 CareerBuilder은 지금은 내가 ..., X 또는 Y 등으로 즉 내 ListView에, CareerBuilder에서 클릭 할 때 동적으로 이름을 변경하려면입니다.

어떻게 수행하나요?

감사

답변

1

내가 코드를 아래에 사용되는 동일한 응용 프로그램이 ..... HTML 파일에

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> 
    <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/> 
        [email protected] 
        <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> 
+0

그것은 나를 위해 일하지 .. . – Udaykiran

+0

뭐죠? ?????? –

+0

대체 할 물건을 얻을 수 없습니다, 나는 스크립트에서 변수를 선언하고이를 대체하기 위해 노력했지만 시도하지 않은 것은 변경되지 않았습니다. – Udaykiran

관련 문제