我是 android开发的新手. 请检查此网址 – http://mobileecommerce.site247365.com/admin/catdata.xml 请检查讲义(cat_name)cat_desc它在android webview中无法正常显示. 我不知道为什么,任何人都可以帮助我或有
请检查此网址 –
http://mobileecommerce.site247365.com/admin/catdata.xml
请检查讲义(cat_name)cat_desc它在android webview中无法正常显示.
我不知道为什么,任何人都可以帮助我或有任何想法吗?
这是我的代码 –
public void startElement(String uri, String localName,String qName, Attributes attributes) throws SAXException { currentTag=localName; Log.v("in start elelmet", "in start elelmet"); if(qName.equals("Table")){ buffer=new StringBuffer(); itemTagStarted=true; item=new NewsItem(); } } @Override public void characters(char[] ch, int start, int length) throws SAXException { if(itemTagStarted){ if(currentTag.equals("Cat_Name")){ item.setCatname(String.valueOf(ch,start,length)); } if(currentTag.equals("Cat_id")){ item.setCatid(String.valueOf(ch,start,length)); } if(currentTag.equals("Cat_Desc")){ buffer.append(String.valueOf(ch,start,length)); } } } @Override public void endElement(String uri, String localName, String qName) throws SAXException { currentTag=""; if(qName.equals("Table")){ itemTagStarted=false; newsList.add(item); } if(qName.equals("Cat_Desc")){ item.setCatdesc(buffer.toString()); Log.v("Description data",buffer.toString()); } } @Override public void endDocument() throws SAXException { Log.v("parsing completed","parsing completed : array size : "+newsList.size()); } }); } catch(Exception ex) { ex.printStackTrace(); }
我的WebView类 –
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); setContentView(R.layout.web_view); Intent intent=getIntent(); String pdf=intent.getStringExtra("str"); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadData(pdf,"text/html", "utf-8");
}
谢谢&问候
Arpit Trivedi
您是否使用WebView#loadDataWithBaseURL(…)来设置Cat_Desc值?我使用简单的SAXParser测试了您的站点,将输出转储到loadDataWithBaseURL并在WebView中获得了可显示的输出.WebView mWebView; mWebView.loadDataWithBaseURL(null,"your_string", "text/html", "utf-8", null);
试试这个;