I have created recyclerView
on fragment with data on arrays.xml
and I have one problem, image not showing in my recyclerView
. I think its a problem in fragment but I am not sure.
This is my distroData.java
private final String mTitle;
private final String mDescription;
private final String mWeb;
private final int mThumbnail;
public DistroData (String title, String description, String web, int thumbnail){
mTitle = title;
mDescription = description;
mWeb = web;
mThumbnail = thumbnail;
}
public String getWeb(){
return mWeb;
}
public int getThumbnail(){
return mThumbnail;
}
public String getTitle(){
return mTitle;
}
public String getDescription(){
return mDescription;
}
}
and this is my fragment :
private void getDatas(){
mGetDatas = new AsyncTask<Void, Void, Boolean>(){
List<PerintahLinuxData> datas;
String[] titles;
String[] descriptions;
int[] thumbnails;
@Override
public void onPreExecute(){
super.onPreExecute();
datas = new ArrayList<>();
titles = getActivity().getResources().getStringArray(R.array.p_title);
descriptions = getActivity().getResources().getStringArray(R.array.p_desc);
thumbnails = getActivity().getResources().getIntArray(R.array.p_thumbnail);
}
and this is my adapter :
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.title.setText(mDatas.get(position).getTitle());
holder.description.setText(mDatas.get(position).getDescription());
holder.thumbnail.setImageResource(mDatas.get(position).getThumbnail());
}
您没有向我们展示适配器更新方法,但我只能猜测您在加载数据后忘记在适配器上使用notifyDataSetChange()
方法。
使用此行,因为您将其图像数组放入了缩略图中。
holder.thumbnail.setImageResource(thumbnails.get(position).getThumbnail());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.