public abstract class AbstractBaseAdapterextends BaseAdapter { List data = new ArrayList (); @Override public int getCount() { if(data!=null){ return data.size(); }else { return 0; } } @Override public Object getItem(int i) { return data.get(i); } @Override public long getItemId(int i) { return i; } public void clear(){ if(data!= null) { data.clear(); } } public void add(T d) { if (d != null&&data!=null) { data.add(d); } } public void addAll(List ds) { if (ds != null&&data!=null) { data.addAll(ds); } } public void remove(int index){ if(data!=null&&data.size()>index&&index>=0){ data.remove(index); } }}
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_file_list, parent, false);
compile 'com.android.support:recyclerview-v7:23.1.1'public abstract class AbstractRecycleViewAdapterextends RecyclerView.Adapter { List data = new ArrayList (); public void clear(){ if(data!= null) { data.clear(); } } public void add(T d) { if (d != null&&data!=null) { data.add(d); } } public void addAll(List ds) { if (ds != null&&data!=null) { data.addAll(ds); } } public T get(int index){ if(data != null&&data.size()>index&&index>=0){ return data.get(index); }else{ return null; } } public void remove(int index){ if(data!=null&&data.size()>index&&index>=0){ data.remove(index); } } @Override public int getItemCount() { if(data!=null){ return data.size(); }else { return 0; } }}
LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL);