本文共 2177 字,大约阅读时间需要 7 分钟。
package com.edaixi.main.adapter;import android.content.Context;import android.support.v4.view.PagerAdapter;import android.text.TextUtils;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView;import java.util.List;/** * Provide views to RecyclerView with data from mDataSet. */public class CommentAdapter extends PagerAdapter { private ListappraiseBeans; private Context context; public CommentAdapter(Context context, List appraiseBeans) { LogUtil.e("come in staruct"); this.appraiseBeans = appraiseBeans; this.context = context; } @Override public int getCount() { return appraiseBeans.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.item_appraise_list, container, false); LogUtil.e("come in adapter"); AppraiseBean appraiseOption = null; if (appraiseBeans.size() > 0) appraiseOption = appraiseBeans.get(position); TextView tv_appraise_content = (TextView) view.findViewById(R.id.tv_appraise_content); TextView tv_appraise_user = (TextView) view.findViewById(R.id.tv_appraise_user); TextView tv_appraise_time = (TextView) view.findViewById(R.id.tv_appraise_time); if (appraiseBeans != null && appraiseBeans.size() == 3) { tv_appraise_content.setLines(2); tv_appraise_content.setEllipsize(TextUtils.TruncateAt.valueOf("END")); } tv_appraise_user.setText(appraiseOption.getUser() + " " + appraiseOption.getTel()); tv_appraise_content.setText(appraiseOption.getComment()); tv_appraise_time.setText(appraiseOption.getCategory() + " " + appraiseOption.getDate()); container.addView(view); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); }}
转载地址:http://hcooa.baihongyu.com/