具有回调功能的Android Retrofit xml

时间:2015-10-16 20:59:02

标签: android retrofit

我一直在关注如何使用xml进行改造... 有效。

How to use Retrofit and SimpleXML together in downloading and parsing an XML file from a site?

但它需要使用回调。而我无法让它发挥作用。

还有其他人做过吗?

public class LocksXmlDisplay {

@Root(name = "breakfast_menu")
public class BreakFastMenu
{
    @ElementList(inline = true)
    List<Food> foodList;
}

@Root(name="food")
public class Food
{
    @Element(name = "name")
    String name;

    @Element(name = "price")
    String price;

    @Element(name = "description")
    String description;

    @Element(name = "calories")
    String calories;
}

public BreakFastMenu breakFastMenu;

}

public interface GetKnocksInter {
@GET("/simple.xml")
//LocksXmlDisplay getxml();
void fetchxml(Callback<List<LocksXmlDisplay.Food>> mycallback);

}

            getKnocksInter.fetchxml(new Callback<List<LocksXmlDisplay.Food>>() {
            @Override
            public void success(List<LocksXmlDisplay.Food> foods, Response response) {

            }

            @Override
            public void failure(RetrofitError error) {

            }
        });

0 个答案:

没有答案