안녕하세요. xml을 구문 분석하고 웹 뷰에로드하는 중 구문 분석 후 하나의보기에 모든 문자열을 추가 할 수 있도록 4 개의 문자열을 만듭니다. 웹보기에서 두 개의보기를 얻을 수 있지만 처음 두 개의 문자열은 가져올 수 없습니다.android에서 webview에 HTML 문자열을 전달하는 방법
Pls에서 코드를 제안합니다. 어디서 잘못 가고 있으며, 웹보기에서 형식이 지정된 html 문자열을 가져 오는 올바른 방법은 무엇입니까? Pls는 내 코드를보고이 문제를 해결할 수 있도록 도와줍니다.
@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;
}
}
나는 웹보기에 chapterIntro 및 chaptercontent를 얻을 수 있지만 처음 두 문자열 PLS 나에게 친구를 도울 수입니다.
내가 그와 함께했는데, 여전히도 loadbaserul – cavallo
과 노력 발생하지 않는 것이 자바 스크립트를 포함한 캐릭터와 함께 작동하도록되어? 그것은 작동하지 않습니다 – Edu
그것은'webView.loadData (yourData, "text/html; charset = utf-8", "UTF-8");' – Jaroslav