Guest User

FilterBaseAdapter.java

a guest
Nov 3rd, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import android.content.Context;
  2. import android.view.LayoutInflater;
  3. import android.view.View;
  4. import android.view.ViewGroup;
  5. import android.widget.BaseAdapter;
  6. import android.widget.TextView;
  7.  
  8. import java.util.ArrayList;
  9.  
  10. public class FilterBaseAdapter extends BaseAdapter {
  11. Context context;
  12. ArrayList<Student> filteredStudents;
  13.  
  14. public FilterBaseAdapter(Context c, ArrayList<Student> ls) {
  15. context = c;
  16. filteredStudents = ls;
  17. }
  18.  
  19. @Override
  20. public int getCount() {
  21. return filteredStudents.size();
  22. }
  23.  
  24. @Override
  25. public Object getItem(int i) {
  26. return filteredStudents.get(i);
  27. }
  28.  
  29. @Override
  30. public long getItemId(int i) {
  31. return i;
  32. }
  33.  
  34. @Override
  35. public View getView(int i, View view, ViewGroup viewGroup) {
  36. if (view == null) {
  37. LayoutInflater mInflater = (LayoutInflater) context.getSystemService(FilterStudents.LAYOUT_INFLATER_SERVICE);
  38. view = mInflater.inflate(R.layout.listview_cell, null);
  39. }
  40.  
  41. //Assign values to custom cell's GUI elements (NOT DONE YET)
  42. //Step 1. Call GUI TextViews (DONE)
  43. TextView filter_u = view.findViewById(R.id.tv_cell_u);
  44. TextView filter_f = view.findViewById(R.id.tv_cell_f);
  45. TextView filter_l = view.findViewById(R.id.tv_cell_l);
  46. TextView filter_e = view.findViewById(R.id.tv_cell_e);
  47. TextView filter_a = view.findViewById(R.id.tv_cell_age);
  48. TextView filter_GPA = view.findViewById(R.id.tv_cell_GPA);
  49. TextView filter_m = view.findViewById(R.id.tv_cell_majorName);
  50.  
  51. //Step 2: retrieve what to set each text box to (NOTE TO SELF MUST TEST)
  52. final int position = i;
  53.  
  54. filter_u.setText(filteredStudents.get(i).getuName());
  55. filter_f.setText(filteredStudents.get(i).getfName());
  56. filter_l.setText(filteredStudents.get(i).getlName());
  57. filter_e.setText(filteredStudents.get(i).geteMail());
  58. filter_a.setText(filteredStudents.get(i).getAge().toString());
  59. filter_GPA.setText(filteredStudents.get(i).getGPA().toString());
  60. filter_m.setText(filteredStudents.get(i).getMajor());
  61.  
  62. return view;
  63. }
  64. }
Add Comment
Please, Sign In to add comment