0
我正在實現android中的recyler視圖。arraylist顯示列表的正確大小,當我調試代碼的適配器也set.But列表項不顯示可能是由於createViewHolder和bindviewHolder.Below是RecyclerViewAdapterRecyclerView在Android中沒有顯示列表項
的代碼MyAdapter.java
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
public Context c;
View img_View;
File file;
public ArrayList<Bean> arr= new ArrayList<>();
LayoutInflater inflator;
public MyAdapter(Context applicationContext, ArrayList<Bean> arr) {
this.c = applicationContext;
this.arr= arr;
inflator = LayoutInflater.from(c.getApplicationContext());
}
@Override
public MyAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
img_View =inflator.inflate(R.layout.list_row, parent, false);
return new MyViewHolder(img_View);
}
@Override
public void onBindViewHolder(MyAdapter.MyViewHolder holder, int position) {
holder.title.setText(arr.get(position).gettitle());
}
@Override
public int getItemCount() {
return arr.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView desc, title;
public MyViewHolder(View view) {
super(view);
title = (TextView) view.findViewById(R.id.tv_title);
}
}
我已經嘗試過這一點,但不是working.Any其他的解決辦法,請 –