【跟我读python3文档】:001_编程的本质是什么!(上)
【开发教程】Swift3.0 做高仿"斗鱼”APP(源代码+视频)完结!
【原创+福利】HTML5教程+React Native跨平台开发(连载)
【大数据Hadoop】【度盘】CentOS Hadoop2.6 集群环境配置教程
android组件 RecyclerView使用教程 第一发:基础使用
<span style="line-height: 1.5; background-color: rgb(255, 255, 255);">dependencies {</span> <span style="line-height: 1.5; background-color: rgb(255, 255, 255);"> compile'com.android.support:recyclerview-v7:23.1.1'</span> <span style="line-height: 1.5; background-color: rgb(255, 255, 255);">}</span>
recyclerView.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
package com.xiaohei.recyclerview; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.ArrayList; import java.util.List; /** * Created by xiaohei on 2016/5/5. */ public class RecyclerviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { List<String> Items; public RecyclerviewAdapter() { Items = new ArrayList<>(); for(int i = 0 ; i<100;i++){ Items.add("小黑 " + i); } } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_item,null); RecyclerView.ViewHolder holder= new xiaoheiHolder(view); return holder; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { xiaoheiHolder XHolder = (xiaoheiHolder) holder; XHolder.mTextView.setText(Items.get(position)); } @Override public int getItemCount() { return Items.size(); } class xiaoheiHolder extends RecyclerView.ViewHolder{ TextView mTextView; public xiaoheiHolder(View itemView) { super(itemView); mTextView = (TextView) itemView.findViewById(R.id.item_id); } } }
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_item,null); RecyclerView.ViewHolder holder= new xiaoheiHolder(view); return holder; }