我已经使用listview.getCount()
在Recyclerview
的情况下如何获得计数
id = receiver + "-" + splashList.getCount();
适配器中的自定义方法:
public void setImage(String my_image, String r_image) {
byte[] decodedrimage = Base64.decode(r_image, Base64.DEFAULT);
Bitmap decodedrByte = BitmapFactory.decodeByteArray(decodedrimage, 0,
decodedrimage.length);
if (my_image.equals("empty")) {
imgflag = 1;
} else {
byte[] decodedmyimage = Base64.decode(my_image, Base64.DEFAULT);
Bitmap decodedmyByte = BitmapFactory.decodeByteArray(
decodedmyimage, 0, decodedmyimage.length);
rimage = createCirclebitmap(decodedrByte);
myimage = createCirclebitmap(decodedmyByte);
}
}
并在另一个类中调用该方法:
CustomListAdapter1 mAdapter ;
mAdapter = new CustomListAdapter1(NewUI.this, dummy,
imgpath, bitmap, id, dateList);
mAdapter.setImage(myimage, rimage);
最佳答案
没有对等的东西。 RecyclerView
不直接了解基础数据集。最近的是
int count = 0;
if (recyclerViewInstance.getAdapter() != null) {
count = recyclerViewInstance.getAdapter().getItemCount();
}
或者,如果您有对适配器的引用,只需致电
int count = 0;
if (mAdapter != null) {
count = mAdapter.getItemCount();
}