Merhaba, ayrıştırmadan sonra xml'yi ayrıştırıyorum ve sonra web görünümüne yüklüyorum, tüm dizeleri bir görünüme ekleyebilmem için dört dizge oluşturuyorum. Web görünümünde iki görünüm alabiliyorum, ancak ilk iki dizeyi göremiyorum.Android web görünümüne html dizgisini nasıl geçiririm
Pls bana kodumu önerir, nerede yanlış gidiyorum ve web görünümünde biçimlendirilmiş html dizelerini almanın doğru yolu nedir? Pls koduma bir göz at ve bu sorunu çözmeme yardım et.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String chapterTitle = "";
String SubChapterTitle="";
String chapterIntro ="";
String chapterContent="";
View view = convertView;
if (convertView == null) {
// view = inflater.inflate(resourceid, null);
view = getLayoutInflater().inflate(R.layout.webviewitem, null);
}
synchronized (view) {
WebView wv = (WebView) view.findViewById(R.id.contentWebView);
WebSettings settings = wv.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
settings.setDefaultZoom(ZoomDensity.FAR);
// wv.setBackgroundColor(0);
wv.setVerticalScrollBarEnabled(false);
wv.setHorizontalScrollBarEnabled(false);
/*String txtChapTitle = Intro.book.getsecretList().get(position)
.getChtitle().toString();*/
if (!(Intro.book.getsecretList().get(position).getChtitle()
.toString().equals(""))){
chapterTitle = "<b><fontSize=4>"+Intro.book.getsecretList().get(position)
.getChtitle().toString()+"</font></b>";
}
if (!(Intro.book.getsecretList().get(position)
.getSubtitle() == null)) {
SubChapterTitle = "<b><fontSize=4>"+Intro.book.getsecretList().get(position)
.getSubtitle().toString()+"</font></b>";
}
if (!(Intro.book.getsecretList().get(position)
.getIntro() == null)) {
chapterIntro = "<b><fontSize=2>"+Intro.book.getsecretList().get(position)
.getIntro().toString()+"</font></b>";
}
if (!(Intro.book.getsecretList().get(position)
.getContent() == null)) {
chapterContent = "<fontSize=2>"+Intro.book.getsecretList().get(position)
.getContent().toString()+"</font>";
}
StringBuilder content = new StringBuilder();
content.append(chapterTitle+SubChapterTitle+chapterIntro+chapterContent);
JsInterface Jsi = new JsInterface();
Jsi.wordDef = content ;
Log.v("Content", "" +content);
wv.addJavascriptInterface(Jsi, "interfaces");
wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
view.setHapticFeedbackEnabled(false);
}
});
wv.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url,
String message, JsResult result) {
return super.onJsAlert(view, url, message, result);
}
});
wv.loadUrl("file:///android_asset/wordview.html");
}
return view;
}
}
ben web görünümü üzerinde chapterIntro ve chaptercontent alabiliriz, ancak ilk iki dizeleri pls bana arkadaş yardımcı duyuyorum.
i bununla çalıştı, hala da loadbaserul – cavallo
ile çalıştı olmuyor o javascript içeren bir dize ile çalışmak gerekiyordu? Bu benim için çalışmıyor – Edu
webView.loadData olmalıdır (seninData, "text/html; charset = utf-8", "UTF-8"); – Jaroslav