日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android view 随机位置,android-如何在RecyclerView之间随机放置广告?

發布時間:2024/9/30 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android view 随机位置,android-如何在RecyclerView之间随机放置广告? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我在應用程序中使用了FastAdapter,我想在RecyclerView之間隨機放置廣告.例如,例如,在3個RecyclerView項目之后,然后在4個項目之后,然后在2個項目之后的廣告,依此類推.

這就是我使用FastAdapter的方式:

FastItemAdapter fastItemAdapter = new FastItemAdapter<>();

fastItemAdapter.withSelectable(true);

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

recyclerView.setHasFixedSize(true);

recyclerView.setLayoutManager(linearLayoutManager);

recyclerView.setItemAnimator(new DefaultItemAnimator());

HRequest hRequest = new HRequest(imageUID);

fastItemAdapter.add(helpRequest);

recyclerView.setAdapter(fastItemAdapter);

這是HRequest.java文件的代碼:

public class HRequest extends AbstractItem {

public String imageURL;

public HRequest() {

}

public HRequest(String imageURL) {

this.imageURL = imageURL;

}

// Fast Adapter methods

@Override

public int getType() {

return R.id.recycler_view;

}

@Override

public int getLayoutRes() {

return R.layout.h_request_list_row;

}

@Override

public void bindView(ViewHolder holder) {

super.bindView(holder);

holder.imageURL.setText(imageURL);

}

// Manually create the ViewHolder class

protected static class ViewHolder extends RecyclerView.ViewHolder {

TextView imageURL;

public ViewHolder(View itemView) {

super(itemView);

imageURL = (TextView)itemView.findViewById(R.id.imageURL);

if (!imageURL.getText().toString().isEmpty()) {

if (imageURL.getText().toString().startsWith("https://firebasestorage.googleapis.com/") || imageURL.getText().toString().startsWith("content://")) {

Picasso.with(itemView.getContext())

.load(imageURL.getText().toString())

.into(homelessImage);

} else {

Toast.makeText(itemView.getContext(), "some problem", Toast.LENGTH_SHORT).show();

}

} else {

Toast.makeText(itemView.getContext(), "no imageUID found", Toast.LENGTH_SHORT).show();

}

}

}

}

我怎樣才能實現自己想要的?

總結

以上是生活随笔為你收集整理的android view 随机位置,android-如何在RecyclerView之间随机放置广告?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。