Issue
I am new in android development.
Please check this url -
http://mobileecommerce.site247365.com/admin/catdata.xml
Please check handout's (Cat_name) cat_desc it is not showing properly in android webview.
I don't know why, can anyone help me or having any idea?
This is my code-
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();
}
My WebView Class-
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");
}
Thanks & Regards
Arpit Trivedi
Solution
Are you using WebView#loadDataWithBaseURL(...) to set your Cat_Desc value? I tested your site with a simple SAXParser, dumping the output into loadDataWithBaseURL and got a displayable output in the WebView.
WebView mWebView;
mWebView.loadDataWithBaseURL(null,"your_string", "text/html", "utf-8", null);
try this;
Answered By - mAc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.