Android 在安卓系统中使用改型时,为什么不显示来自服务器的帖子

Android 在安卓系统中使用改型时,为什么不显示来自服务器的帖子,android,android-adapter,retrofit2,android-json,Android,Android Adapter,Retrofit2,Android Json,我想使用reformation从服务器加载数据,并使用DataModel设置和获取数据 mContext.startActivity(new Intent(v.getContext(), Category_page.class) .putExtra("categoryTitle", model.getTitle()) .putExtra("categoryID", model.getId())); 这就是我想做的。当我点击一个类别时,我想在另一个活动中看到该类别

我想使用
reformation
从服务器加载数据,并使用
DataModel
设置和获取数据

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
这就是我想做的。当我点击一个类别时,我想在另一个
活动中看到该类别的帖子

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
为了显示分类帖子,我使用以下链接:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
对于筛选,我使用
类别id

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
例如:通过这个链接,我看到了Category1中的所有帖子

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
我的
改装接口
用于设置链接:(我在其他类中设置
基本url

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
并使用以下代码接收此数据:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
// Receive Data
bundle = getIntent().getExtras();
catID = bundle.getInt("categoryID");
但是错误消息(
Toast
)而不是类别帖子

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
从以下位置显示错误土司:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
@Override
public void onFailure(Call<R_CatModelResponse> call, Throwable t) {
    Toast.makeText(Category_page.this, "Error", Toast.LENGTH_SHORT).show();
}
更新#2:
添加了我的POJO类:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
public class R_CatModelResponse {

    @SerializedName("status")
    public String Cat_status;
    @SerializedName("count")
    public int Cat_count;
    @SerializedName("pages")
    public int Cat_pages;
    @SerializedName("category")
    public List<Retrofit_ColoniesModel> category;
    @SerializedName("posts")
    public List<R_CatModel> Cat_posts;

    public String getCat_status() {
        return Cat_status;
    }

    public void setCat_status(String cat_status) {
        Cat_status = cat_status;
    }

    public int getCat_count() {
        return Cat_count;
    }

    public void setCat_count(int cat_count) {
        Cat_count = cat_count;
    }

    public int getCat_pages() {
        return Cat_pages;
    }

    public void setCat_pages(int cat_pages) {
        Cat_pages = cat_pages;
    }

    public List<Retrofit_ColoniesModel> getCategory() {
        return category;
    }

    public void setCategory(List<Retrofit_ColoniesModel> category) {
        this.category = category;
    }

    public List<R_CatModel> getCat_posts() {
        return Cat_posts;
    }

    public void setCat_posts(List<R_CatModel> cat_posts) {
        Cat_posts = cat_posts;
    }
}
公共类R\u CatModelResponse{
@序列化名称(“状态”)
公共字符串Cat_状态;
@序列化名称(“计数”)
公共int Cat_计数;
@序列化名称(“页面”)
公共int Cat_页面;
@序列化名称(“类别”)
公开名单类别;
@序列化名称(“帖子”)
公开名单Cat_职位;
公共字符串getCat_status(){
返回Cat_状态;
}
公共无效设置cat_状态(字符串cat_状态){
Cat_状态=Cat_状态;
}
公共整数getCat_count(){
返回Cat_计数;
}
公共无效设置类别计数(int类别计数){
Cat_计数=Cat_计数;
}
public int getCat_pages(){
返回Cat_页面;
}
公共无效设置目录页(int目录页){
Cat_页面=Cat_页面;
}
公共列表getCategory(){
退货类别;
}
公共类别(列表类别){
this.category=类别;
}
公共列表getCat_posts(){
返回Cat_岗位;
}
公共无效设置cat_POST(列出cat_POST){
Cat_柱=Cat_柱;
}
}
我怎样才能解决这个问题

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
请帮帮我。提前感谢。

请参阅使您的生活更轻松的模式:D,基于此,请使用以下结构:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
您的数据模型应该是:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
public class Model {

    String status;
    int count;
    int page;
    Category category;
    List<Post> posts;

    // implement rest of thing

    public class Category{

        int id;
        String slug;
        String title;
        String description;
        int parent;
        int post_count;
    }

    public class Post {
        int id;
        String type;
        String slug;
        //..rest of thing
    }

}
public interface IService {

        @GET("/tafrihgah/?json=get_category_posts")
        Call<Model> getCategoryPost(
                @Query("id") String id

                //...other query if you need should added like below
               @Query("categorySlug") String categorySlug,
               @Query("tag") String tag,
        );
    }
您的
serviceheloper
包含以下方法:

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
public Call<CategoryModel> getAllCategory() {
    return service.getCateogryPost();
}
public调用getAllCategory(){
return service.getCategryPost();
}
您的错误会导致您的
POJO
不适合服务器型号。仔细检查您的模型,确保
对象
而不是
列表/数组

mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));

在您的情况下,不要使用
列表类别
而使用
改型\u ColoniesModel类别

从响应中,您将类别作为数组而不是对象,请检查您将类别定义为对象的POJO类。换成list@MohammadNouri
R\u CatModelResponse
是您的POJO课程。您能展示一下您的POJO课程吗
R\u CatModelResponse
?salam,amir jan id telegram dari?@MohammadNouri您好亲爱的Mohammad,请在这里解释您的问题,我非常乐意帮助您解决您的问题,我也测试了你的请求,我成功了。像切·塔吉拉蒂·巴亚德·贝达姆那样的武装是什么?亲爱的Mohammad,我看到你的POJO使用列表,而你的类别不是列表,它是简单的对象。看看我的模型类和类别属性。FAQAAAAAAAAAAAAAAT HAAAAAAMIN?!!!!阿兹·索布·达尔·吉里南!谢谢,我亲爱的朋友
mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));