webview from json

You must Login before you can answer or comment on any questions.

i've simple problems... my client send me json to consume in device,,,, he send a news content like

1.news_id

2.title

3.excerpt

4.content

he also send a content with html tags... like

<p><span style="\"color:" font-family:="" line-height:="">Olah raga drifting di
  tanah air\U00a0 tahun 2012 ini sepertinya mempunyai satu lagi perkumpulan
  drifter-drifter lokal yaitu Indonesian All Star Drift Asociation.</span></p>
 
  <p style="\"text-align:"><span style="\"line-height:">Anggota dari Indonesia
  All Star Drift Association<img title="\"Anggota" dari="" indonesia="" all="" star=
  "" drift="" src=
  "/"http://cdn.sportku.com/uploads/article-images/anggota-dari-indonesia-all-star-drift-association-201204040205213122.JPG/""
  alt="\"Drift," indonesia="" all="" star="" drift="" width=
  "\"605\"" /></span></p>
 
  <p><span style="\"color:" font-family:="" line-height:="">Ditemui di Exlusive Auto
  Garage pada minggu malam 1 April 2012 kami mewawancarai drifter pro Emmanuel Adwitya
  Amandio selaku ketua Indonesian All Star Drift Association.\U00a0</span></p>
 
  <p style="\"text-align:"><span style="\"color:" font-family:="" line-height:=
  "">Ki-ka : Adwitya Amandio, Rayhan Ally, TB Deyang, Herdiko SP, Dika CH, M.Hermawan,
  Tyo Anand<img title="\"Kiri-Kanan" adwitya="" rayhan="" tb="" herdiko="" dika=""
  tyo="" src=
  "/"http://cdn.sportku.com/uploads/article-images/kirikanan-adwitya-amandio-rayhan-ally-tb-deyang-herdiko-sp-dika--201204040206034786.JPG/""
  alt="\"Drift," indonesia="" all="" star="" drift="" width=
  "\"605\"" /></span></p>\n
 
  <p style="\"margin:" text-align:="" font:="" color:="">Dalam penjelasannya
  Emannuel Adwitya Amandio menjelaskan bahwa perkumpulan ini\U00a0 mempunyai 6 anggota
  lainya yaitu Rayhan Alley, Tb.Deyang, Dika CH, Tyo Ananda, Herdiko SP dan
  M.Hermawan.\U00a0</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">\U00a0</p>
 
  <p style="\"margin:" font:="" color:="">Amandio atau panggilan akrabnya Dio
  menjelaskan Indonesian All Star \nDrift Assosiation terbentuk pada 23 Maret 2012 di
  salah satu restoran \nhotel di Jakarta.</p>\n
 
  <p style="\"margin:" text-align:="" font:="" color:="">\U00a0</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">Pemotongan tumpeng oleh
  ketua Indonesia All Star Drift Association, Adwitya Amandio<img title=
  "\"Pemotongan" tumpeng="" oleh="" ketua="" indonesia="" all="" star="" drift=""
  adwitya="" src=
  "/"http://cdn.sportku.com/uploads/article-images/pemotongan-tumpeng-oleh-ketua-indonesia-all-star-drift-association-20120404021107-4633.JPG/""
  alt="\"Drift," indonesia="" all="" star="" drift="" width=
  "\"605\"" /></p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">\U00a0</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">Selain itu salah satu
  tujuan kehadiran Indonesian All Star Drift Assosiation adalah memajukan drifting
  Indonesia dengan cara menyatukan drifter-drifter pro dan rokie walaupun berasal dari
  tim, klub ataupun sponsor yang berbeda.</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">\U00a0</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">Pada malam itu juga Amandio
  dan teman-teman drifter dari Indonesian All \nStar Drift Association mengadakan 'soft
  launching' dengan acara doa dan \npotong tumpeng bersama.</p>
 
  <p style="\"margin:" text-align:="" font:="" color:="">\U00a0</p>
 
  <p style="\"font:" normal="" normal="" normal="" color:="" text-align:="" margin:=
  ""><span style="\"font-family:" color:="">Indonesia All Star Drift
  Association</span><img title="\"Indonesia" all="" star="" drift="" src=
  "/"http://cdn.sportku.com/uploads/article-images/indonesia-all-star-drift-association-20120404021107-7849.JPG/""
  alt="\"Drift," indonesia="" all="" star="" drift="" width=
  "\"605\"" /></p>";
and the quoestion is,,, how to draw it to webvieW? is that need to create own css files?

how about hyperlink there? -should i put html tags such a body rtc

2 Answers

Accepted Answer

Hi Arie,

Try to setHtml() in your code as,

var strHTML = '<html><head>
    <LINK href="'+ YourExternalStylesheetHere + '" rel="stylesheet" type="text/css">
    <title>' +
     YourTitleHere
    +'<title></head><body>' +
    yourHTMLDataHere
    + '</body></html>'

— answered 2 years ago by Gaurang Chhatbar
answer permalink
1 Comment
  • thanks brorrrr its running

    var innerHTML = '<html><link rel="stylesheet" href="lib/style.css"><body> <div id="content"><h1>' + judul + '</h1>' + content_web + '</div></body></html>';
                    var y = Ti.UI.createWebView({
                        height : Ti.UI.SIZE,
                        width : Ti.UI.SIZE,
                        html : innerHTML,
                        enableZoomControls : false,
                        focusable : true,
     
                    });

    — commented 2 years ago by Arie Prasetyo

Hi Arie,

Have you tried using html property of webview. and also refere this that may help you.

Your Answer

Think you can help? Login to answer this question!