java - parsing xml data in android using sax -
i have develop 1 android xml parsing using sax app.
here displayed category-name , article title belonging category on single listview...its done well..
but requirement category name display on gridview , article title display on horizontal listview below corresponding category.
here have utilize below code means getting next error:
the method setadapter(listadapter) in type horizontallistview not applicable arguments (string)
laptop.java:
public class laptop { private string model; private string brand; public string getmodel() { homecoming model; } public void setmodel(string model) { this.model = model; } public string getbrand() { homecoming brand; } public void setbrand(string brand) { this.brand = brand; }}
in saxxmlhandler.java
public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception { // reset tempval = ""; if (qname.equalsignorecase("category")) { // create new instance of laptop laptop = new laptop(); laptop.setbrand(attributes.getvalue("name")); } else if (qname.equalsignorecase("article")) { // create new instance of laptop article = new laptop(); article.setmodel(attributes.getvalue("title")); }
in customlistviewadapter.java
public class customlistviewadapter extends arrayadapter<laptop> { activity context; list<laptop> laptops; public customlistviewadapter(context context2, list<laptop> laptops) { super(context2, r.layout.list_item, laptops); this.context = (activity) context2; this.laptops = laptops; } /*private view holder class*/ private class viewholder { imageview imageview; horizontallistview txtmodel; textview txtbrand; textview txtprice; } public laptop getitem(int position) { homecoming laptops.get(position); } public view getview(int position, view convertview, viewgroup parent) { viewholder holder; layoutinflater inflater = context.getlayoutinflater(); if (convertview == null) { convertview = inflater.inflate(r.layout.list_item, null); holder = new viewholder(); holder.txtmodel = (horizontallistview) convertview.findviewbyid(r.id.model); holder.txtbrand = (textview) convertview.findviewbyid(r.id.brand); // holder.txtprice = (textview) convertview.findviewbyid(r.id.price); // holder.imageview = (imageview) convertview.findviewbyid(r.id.thumbnail); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } laptop laptop = (laptop) getitem(position); // holder.txtmodel.settext(laptop.getmodel()); holder.txtbrand.settext(laptop.getbrand()); // holder.imageview.setimagebitmap(laptop.getimagebitmap()); // holder.txtprice.settext(laptop.getprice() + ""); holder.txtmodel.setadapter(laptop.getmodel()); homecoming convertview; }}
in horizontallistview.java
public void setadapter(listadapter adapter) { if(madapter != null) { madapter.unregisterdatasetobserver(mdataobserver); } madapter = adapter; madapter.registerdatasetobserver(mdataobserver); reset(); }
am getting above error in below line:
holder.txtmodel.setadapter(laptop.getmodel());
how can resolve these ??? how can article title on horizontal listview below corresponding category...
i sugest read link, tratamiento de xml en android (i): sax
leer/parsear archivo xml en android mediante sax
good luck
java android xml-parsing saxparser listadapter
No comments:
Post a Comment