android适配器的简单使用1. private ListView listView;// 列表组件public static ArrayList<NutritionListViewBean> list = new ArrayList<NutritionListViewBean>();// 数据源private NutritionAdapter adapter;// 适配器2. // 创建适配器对象adapter = new NutritionAdapter(this);// 设定数据源loadData();// 设置数据源adapter.setList(list);// 将适配器设置到ListView中listView.setAdapter(adapter);3.public class NutritionAdapter extends BaseAdapter {// 设置组视图的数据源private ArrayList<NutritionListViewBean> list = new ArrayList<NutritionListViewBean>();// 设置数据源public void setList(ArrayList<NutritionListViewBean> list) {this.list = list;}// 加载布局private LayoutInflater mInflater;public NutritionAdapter(Context context) {mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);}@Overridepublic int getCount() {return list.size();}@Overridepublic Object getItem(int arg0) {return list.get(arg0);}@Overridepublic long getItemId(int arg0) {return arg0;}@Overridepublic View getView(int position, View convertView, ViewGroup arg2) {final GroupViewHolder holder;if (null == convertView) {convertView = mInflater.inflate(R.layout.listview_nutrition, null);holder = new GroupViewHolder();holder.listNutritionImageView = (com.yongting.view.CircleImage) convertView.findViewById(R.id.listNutritionImageView);convertView.setTag(holder);} else {holder = (GroupViewHolder) convertView.getTag();}// 从List中得到一个BeanNutritionListViewBean bean = list.get(position);// 点击分享holder.listNutritionShareImageView.setTag(position);holder.listNutritionShareImageView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {}});// 职称holder.listNutritionProfessionalRankTextView.setText(bean.getProfessional_rank());}class GroupViewHolder {com.yongting.view.CircleImage listNutritionImageView;TextViewlistNutritionProfessionalRankTextView;}}
推荐整理分享android适配器的简单使用(android中适配器),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:android 适配,安卓适配器使用方法,android中适配器,android常用的三种适配器,安卓适配器使用方法,android适配器ui,android适配器ui,android 适配器,内容如对您有帮助,希望把文章链接给更多的朋友!
android使用ImageLoader显示圆角图片 android使用ImageLoader显示圆角图片第一步:.定义工具类ImageLoaderUtils_circle(关键地方:displayer(newRoundedBitmapDisplayer())//是否设置为圆角,弧度为多少)publ
android DefaultHttpClient设置setCookieStore androidDefaultHttpClient设置setCookieStore第一步:设置CookieStoreUtils的工具类importjava.util.Iterator;importjava.util.List;importjava.util.Map;importorg.apache.http.client.CookieStore;imp
android检查sd卡是否插上 android检查sd卡是否插上/***检查sd卡是否插上**@return*/publicstaticbooleanonCheckSDScardExist(){if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){returntrue;}els