TakashiYamamot

Untitled

Jan 29th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public class MyAppAdapter extends BaseAdapter //has a class viewholder which holds
  2. {
  3. public class ViewHolder
  4. {
  5. TextView textName;
  6. ImageView imageView;
  7. }
  8.  
  9. public List<ClassListItems> parkingList;
  10.  
  11. public Context context;
  12. ArrayList<ClassListItems> arraylist;
  13.  
  14. private MyAppAdapter(List<ClassListItems> apps, Context context)
  15. {
  16. this.parkingList = apps;
  17. this.context = context;
  18. arraylist = new ArrayList<ClassListItems>();
  19. arraylist.addAll(parkingList);
  20. }
  21.  
  22. @Override
  23. public int getCount() {
  24. return parkingList.size();
  25. }
  26.  
  27. @Override
  28. public Object getItem(int position) {
  29. return position;
  30. }
  31.  
  32. @Override
  33. public long getItemId(int position) {
  34. return position;
  35. }
  36.  
  37. @SuppressLint("SetTextI18n")
  38. @Override
  39. public View getView(final int position, View convertView, ViewGroup parent) // inflating the layout and initializing widgets
  40. {
  41.  
  42. View rowView = convertView;
  43. ViewHolder viewHolder= null;
  44. if (rowView == null)
  45. {
  46. LayoutInflater inflater = getLayoutInflater();
  47. rowView = inflater.inflate(R.layout.list_content, parent, false);
  48. viewHolder = new ViewHolder();
  49. viewHolder.textName = (TextView) rowView.findViewById(R.id.textName);
  50. viewHolder.imageView = (ImageView) rowView.findViewById(R.id.imageView);
  51. rowView.setTag(viewHolder);
  52. }
  53. else
  54. {
  55. viewHolder = (ViewHolder) convertView.getTag();
  56. }
  57. // here setting up names and images
  58. viewHolder.textName.setText(parkingList.get(position).getName()+"");
  59.  
  60. return rowView;
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment