on
Android App Study_29 (RecyclerView with Firebase)
Android App Study_29 (RecyclerView with Firebase)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
package com.example.firebaseliststudy; import ... public class CustomAdapter extends RecyclerView.Adapter < CustomAdapter.CustomViewHolder > { private ArrayList < User > arrayList; private Context context; public CustomAdapter(ArrayList < User > arrayList, Context context) { this .arrayList = arrayList; this .context = context; } @NonNull @Override public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false ); CustomViewHolder holder = new CustomViewHolder(view); return holder; } @Override public void onBindViewHolder(@NonNull CustomViewHolder holder, int position) { Glide.with(holder.itemView) .load(arrayList.get(position).getProfile()) .into(holder.iv_p); holder.tv_id.setText(arrayList.get(position).getId()); holder.tv_pw.setText( String . valueOf (arrayList.get(position).getPw())); holder.tv_name.setText(arrayList.get(position).getUserName()); } @Override public int getItemCount() { return (arrayList ! = null ? arrayList.size() : 0 ); } public class CustomViewHolder extends RecyclerView.ViewHolder { ImageView iv_p; TextView tv_id; TextView tv_pw; TextView tv_name; public CustomViewHolder(@NonNull View itemView) { super (itemView); this .iv_p = itemView.findViewById(R.id.iv_p); this .tv_id = itemView.findViewById(R.id.tv_id); this .tv_pw = itemView.findViewById(R.id.tv_pw); this .tv_name = itemView.findViewById(R.id.tv_name); } } } Colored by Color Scripter
from http://yunseong.tistory.com/54 by ccl(A) rewrite - 2021-11-27 14:02:29