微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

tikxml 没有 TypeAdapter

如何解决tikxml 没有 TypeAdapter

build.gradle

 implementation 'com.tickaroo.tikxml:annotation:0.8.13'
    implementation 'com.tickaroo.tikxml:core:0.8.13'
    implementation 'com.tickaroo.tikxml:retrofit-converter:0.8.13'

文档.class

@Xml(name = "docs")
public class docs {
    @Attribute(name = "docs")
    public ArrayList<doc> doc = new ArrayList <>();

}

文档类

public class doc {
    @PropertyElement(name="bookname")
    String bookname;
    @PropertyElement(name="authors")
    String authors;
    @PropertyElement(name="isbn13")
    String isbn13;
    @PropertyElement(name="bookImageURL")
    String bookImageURL;
    public doc(){

    }
    public doc(String title,String authors,String isbn13,String bookImageURL) {
        this.bookname = title;
        this.authors = authors;
        this.isbn13 = isbn13;
        this.bookImageURL = bookImageURL;


    }
    public String getTitle() {
        return bookname;
    }
    public void setTitle(String title) {
        this.bookname = title;
    }
    public String getAuthors() {
        return authors;
    }
    public void setAuthors(String authors) {
        this.authors = authors;
    }
    public String getIsbn13() {
        return isbn13;
    }
    public void setIsbn13(String isbn13) {
        this.isbn13 = isbn13;
    }
    public String getBookImageURL() {
        return bookImageURL;
    }
    public void setBookImageURL(String bookImageURL) {
        this.bookImageURL = bookImageURL;
    }



}

main.class

 Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://data4library.kr/api/")
                .addConverterFactory(tikxmlConverterFactory.create(tikxml))
                .build();

        Library retable = retrofit.create(Library.class);
        Call <docs> call = retable.getRes("key","2021-04-11");
        Log.d("request",call.request().toString());
        call.enqueue(new Callback <docs>() {
            @Override
            public void onResponse(Call <docs> call,Response <docs> response) {

                Log.d("Title",livo.get(0).getTitle());
            }

            @Override
            public void onFailure(Call <docs> call,Throwable t) {
         
                Log.d("Test",t.getMessage());
            }
        });


public interface Library {
    @GET("loanItemSrch")
    Call<docs> getRes(
            @Query("authKey") String authKey,@Query("startDt") String startDt

    );
}

enter image description here

使用改造的 XML 解析

您遇到了无法自行解决错误

类没有 TypeAdapKter

用call.request()接收日志时,地址正常

我已连接,但 onFailure() 方法不断向我显示错误消息

我需要你的帮助。谢谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。