我正在开发android应用程序,我想实现具有多个数组列表的Base Adapter类。但我不知道这里实现的是我的代码如下。在我的Activity类中,这是适配器对象 adapter = new Dashboard_Adapter(mContext,arrayList,arrayList_prsndata,arrayList_Comnt,arrayList_pics,arrayList_Feddta);
public class Dashboard_Adapter extends BaseAdapter {
ViewHolder viewHolder;
SharedPreferences sharedPreferences;
private LayoutInflater layoutInflater = null;
ArrayList<String> arr;
private Activity activity;
public Context context;
HashMap<String, String> threadmap;
ArrayList<HashMap<String, String>> arrayList;
ArrayList<HashMap<String, String>> arrayList_prsndata;
ArrayList<HashMap<String, String>> arrayList_Comnt;
ArrayList<HashMap<String, String>> arrayList_pics;
ArrayList<HashMap<String, String>> arrayList_Feddta;
public Dashboard_Adapter(Context dashbord, ArrayList<HashMap<String, String>> arrayLis, ArrayList<HashMap<String, String>> arrayList_prsndata, ArrayList<HashMap<String, String>> arrayList_Comnt, ArrayList<HashMap<String, String>> arrayList_pics, ArrayList<HashMap<String, String>> arrayList_Feeddta) {
activity = (Activity) dashbord;
this.arrayList =arrayLis;
this.arrayList_prsndata =arrayList_prsndata;
this.arrayList_Comnt =arrayList_Comnt;
this.arrayList_pics =arrayList_pics;
this.arrayList_Feddta =arrayList_Feeddta;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
sharedPreferences = activity.getSharedPreferences(Login.My_Prefs, Context.MODE_PRIVATE);
}
@Override
public int getCount() {
return arrayList.size();
}
@Override
public Object getItem(int position) {
return arrayList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
final ViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.newpost, parent, false);
viewHolder = new ViewHolder();
viewHolder.Name = (TextView) view.findViewById(R.id.txtTags);
viewHolder.PageName = (TextView) view.findViewById(R.id.tvPageName);
viewHolder.Time = (TextView) view.findViewById(R.id.tvtimeShow);
viewHolder.Disc = (TextView) view.findViewById(R.id.disc);
viewHolder.PostText = (TextView) view.findViewById(R.id.txtPost);
viewHolder.PostImage = (ImageView) view.findViewById(R.id.imgPost);
viewHolder.PostVideo = (VideoView) view.findViewById(R.id.videoPost);
viewHolder.btnLike = (Button) view.findViewById(R.id.btnTotalLike);
viewHolder.btnDisLike = (Button) view.findViewById(R.id.btnTotalDislikes);
viewHolder.btnComment = (Button) view.findViewById(R.id.btnTotalComment);
viewHolder.btnShare = (Button) view.findViewById(R.id.btnTotalShares);
viewHolder.btnPromote = (Button) view.findViewById(R.id.btnFeedResponce);
viewHolder.btnGreatJobNumber = (Button) view.findViewById(R.id.btnGreatJobNumber);
// viewHolder.btnup.setTag(position);
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
threadmap = new HashMap<>();
threadmap = arrayList.get(position);
viewHolder.btnLike.setText(threadmap.get(Dashboard.like_count));
viewHolder.btnDisLike.setText(threadmap.get(Dashboard.unlike_count));
viewHolder.btnComment.setText(threadmap.get(Dashboard.comment_count));
viewHolder.btnShare.setText(threadmap.get(Dashboard.share_count));
viewHolder.btnPromote.setText(threadmap.get(Dashboard.feed_count));
viewHolder.btnGreatJobNumber.setText(threadmap.get(Dashboard.greatjob_count));
return view;
// Glide.with(context).load(images).placeholder(R.drawable.home).into(imageView);
}
public static class ViewHolder {
TextView Name;
TextView PageName;
TextView Time;
TextView Disc;
TextView PostText;
ImageView PostImage;
VideoView PostVideo;
Button btnLike;
Button btnDisLike;
Button btnComment;
Button btnShare;
Button btnPromote;
Button btnGreatJobNumber;
}
}