文章标题

创建定制列表项布局

把列表项视图剥离为独立的布局文件

更新adapter,使用定制列表项布局

 private class CrimeAdapter extends RecyclerView.Adapter<CrimeHolder> {

      ……
      @Override
      public CrimeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          //创建View视图
          LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
          //把View视图封装到ViewHolder
          //  View view = layoutInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
          View view = layoutInflater.inflate(R.layout.list_item_crime,parent,false);
          return new CrimeHolder(view);
   }
posted on 2017-10-12 15:53  dreamstar  阅读(50)  评论(0编辑  收藏  举报