80,350
社区成员
发帖
与我相关
我的任务
分享
String Temp="";
Temp=""
+ "<style>font{font-size:45px;line-height:60px}body{padding:5px;width:100%;font-size:45px;color:white;line-height:60px;min-width:" + myValue.ScreenWidth + "px;"
+ "font-weight:normal;border:red 2px solid}a{color:white}img{width:100%;min-width:" + myValue.ScreenWidth + "px;border:green 0px solid}"
+ "div{width:100%;border:blue 3px solid;margin:5px;min-width:" + myValue.ScreenWidth + "px}p{width:100%;min-width:" + myValue.ScreenWidth + "px"
+ ";border:white 1px solid;padding:5px;height:auto}"
+ "</style>";
Temp=Temp.replace("<div","<p");
Temp=Temp.replace("</div>", "</p>");
Temp=Temp + cursor.getString(2);//.replace("<p", "<div").replace("</p>", "</div>");
WebView v=(WebView)findViewById(R.id.wv);
v.getSettings().setSupportZoom(true);
v.setBackgroundColor(Color.BLACK);
//v.loadUrl("about:blank");
v.clearCache(true);
v.getSettings().setDefaultTextEncodingName("utf-8");
Log.i("ROBACK", "Default Encoding = " + v.getSettings().getDefaultTextEncodingName());
//v.loadData(new String(Temp).replaceAll("#", "%23").replaceAll("%",
// "%25").replaceAll("\'", "%27"), "text/html", "utf-8");
//v.loadData(Temp, "text/html", "utf-8");
v.loadDataWithBaseURL(null,Temp, "text/html", "utf-8",null);
this.setTitle(cursor.getString(1));
v.setWebViewClient(new WebViewClient(){
public void onReceivedError(WebView view,int errorCode,String description,String failingUrl)
{
Toast.makeText(mContext, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
v.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
WebView v=(WebView)findViewById(R.id.wv);
//Toast.makeText(mContext, v.getUrl() + newProgress +"加载中...", Toast.LENGTH_SHORT).show();
ProgressBar s=(ProgressBar)findViewById(R.id.progressBar1);
s.setMax(100);
s.setProgress(newProgress);
if(newProgress==100){
v.setVisibility(0);
//Toast.makeText(mContext, "加载结束...", Toast.LENGTH_SHORT).show();
}else{
v.setVisibility(8);
//Toast.makeText(mContext, "加载中...", Toast.LENGTH_SHORT).show();
}
}
});