admin管理员组

文章数量:1325367

I am developing WP API. I show you the screen of the problem:

I want to get the main image of wordpress's articles for each article.

MainActivity class:

list.add( new Model( Model.IMAGE_TYPE, response.body().get(i).getTitle().getRendered(),
                     tempdeatils,
             response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref()) );

Model class:

public static final int IMAGE_TYPE =1;
public String title, subtitle, Image;
public int type;

public Model (int mtype, String mtitle, String msubtitle, String image) {
    this.type = mtype;
    this.title = mtitle;
    this.subtitle = msubtitle;
    this.Image = image;
}

}

RetrofitAPI class:

@GET("/wp-json/wp/v2/posts?_categories=14&per_pages=10")
Call<List<WPPost>> getPostInfo();

Recyclerview class:

public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
    final Model object = dataset.get(position);

    ( (ImageTypeViewHolder) holder).title.setText( object.title );
    ( (ImageTypeViewHolder) holder).subtitle.setText( object.subtitle );

    Log.e("Title_", object.title);
    Log.e("Subtitle_", object.subtitle);
    Log.e("Image_", object.Image);

    Glide.with(this.mContext).load(object.Image).into(( (ImageTypeViewHolder) holder).imageView);

    ( (ImageTypeViewHolder) holder).title.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, WPPostDetails.class);
            intent.putExtra("itemPosition", position);
            mContext.startActivity(intent);
        }
    });
    ( (ImageTypeViewHolder) holder).subtitle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, WPPostDetails.class);
            intent.putExtra("itemPosition", position);
            mContext.startActivity(intent);
        }
    });
    ( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, WPPostDetails.class);
            intent.putExtra("itemPosition", position);
            mContext.startActivity(intent);
        }
    });

When I run the App, I get title and part of article but I can't parse the main image of the articles.

Some suggestion?

本文标签: jsonWP Rest API in Android studio does not show Images