RecyclerViewAdapter RecyclerView.Adapter<RecyclerView.ViewHolder> { LayoutInflater ; Context ; String [] ; ITEM_TYPE { , } //下面这段什么意思 RecyclerViewAdapter(Context context,String[] titles){ .= titles; .= context; = LayoutInflater.(context); } RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, viewType) { (viewType == ITEM_TYPE..ordinal()) { Item1ViewHolder(.inflate(R.layout., parent, )); } { Item2ViewHolder(.inflate(R.layout., parent, )); } } onBindViewHolder(RecyclerView.ViewHolder holder, position) { (holder Item1ViewHolder) { ((Item1ViewHolder) holder)..setText([position]); } } getItemViewType(position) { position % == ? ITEM_TYPE..ordinal() : ITEM_TYPE..ordinal(); } getItemCount() { == ? : .; } Item1ViewHolder RecyclerView.ViewHolder{ TextView ; Item1ViewHolder(View itemView) { (itemView); =(TextView)itemView.findViewById(R.id.); } } Item2ViewHolder RecyclerView.ViewHolder{ TextView ; Item2ViewHolder(View itemView) { (itemView); =(TextView)itemView.findViewById(R.id.); } } }
楚人江南留香久
蜂之谷