Import android os. Bundle


Download 141 Kb.
Pdf ko'rish
bet6/15
Sana20.11.2023
Hajmi141 Kb.
#1789524
1   2   3   4   5   6   7   8   9   ...   15
Bog'liq
Qodirov mobil ilovakar 2 dedline

import java.util.List; 
 
public class UserAdapter extends RecyclerView.Adapter { 
 
private List userList; 
 
public UserAdapter(List userList) { 
this.userList = userList; 

 
@NonNull 
@Override 
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user, parent, false); 
return new ViewHolder(view); 

 
@Override 
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { 
User user = userList.get(position); 
holder.bind(user); 

 
@Override 
public int getItemCount() { 
return userList.size(); 

 
static class ViewHolder extends RecyclerView.ViewHolder { 
private final TextView lastNameTextView; 
private final TextView firstNameTextView; 
private final TextView ageTextView; 


private final TextView birthplaceTextView; 
 
public ViewHolder(@NonNull View itemView) { 
super(itemView); 
lastNameTextView = itemView.findViewById(R.id.lastNameTextView); 
firstNameTextView = itemView.findViewById(R.id.firstNameTextView); 
ageTextView = itemView.findViewById(R.id.ageTextView); 
birthplaceTextView = itemView.findViewById(R.id.birthplaceTextView); 

 
public void bind(User user) { 
lastNameTextView.setText("Familya: " + user.getLastName()); 
firstNameTextView.setText("Ism: " + user.getFirstName()); 

Download 141 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling