Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. /**
  2. * List adapter (BaseAdapter), getView
  3. *
  4. */
  5. @Override
  6. public View getView(int position, View convertView, ViewGroup parent) {
  7.  
  8. ViewHolder holder = null;
  9. Car car = (Car) getItem(position);
  10.  
  11. if (convertView == null) {
  12. convertView = mInflater.inflate(R.layout.list_item_cars, null);
  13. holder = new ViewHolder();
  14. holder.carName = (TextView)convertView.findViewById(R.id.car_name);
  15. holder.carGroups = (FlowLayout)convertView.findViewById(R.id.car_groups);
  16. convertView.setTag(holder);
  17. }
  18. else {
  19. holder = (ViewHolder)convertView.getTag();
  20. }
  21.  
  22. holder.carName.setText(car.getName());
  23. buildGroupsFlowLayout(holder.carGroups, car.getGroups());
  24. return convertView;
  25. }
  26.  
  27. /**
  28. * Build FlowLayout
  29. */
  30. private void buildGroupsFlowLayout(FlowLayout flowLayout, List<CarGroup> groupsList) {
  31.  
  32. flowLayout.removeAllViews();
  33. int i = 0;
  34.  
  35. for(CarGroup group : groupsList) {
  36. View groupItemView = mInflater.inflate(R.layout.car_group_item, null);
  37. TextView lineView = (TextView)groupItemView.findViewById(R.id.car_group_item_goup_text);
  38. lineView.setText(group.getName());
  39. lineView.setTextColor(group.getColor());
  40.  
  41. flowLayout.addView(groupItemView, i, new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT));
  42. i++;
  43. }
  44. }
  45.  
  46. public static class ViewHolder {
  47. public TextView carName;
  48. public FlowLayout carGroups;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement