Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * List adapter (BaseAdapter), getView
- *
- */
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder = null;
- Car car = (Car) getItem(position);
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.list_item_cars, null);
- holder = new ViewHolder();
- holder.carName = (TextView)convertView.findViewById(R.id.car_name);
- holder.carGroups = (FlowLayout)convertView.findViewById(R.id.car_groups);
- convertView.setTag(holder);
- }
- else {
- holder = (ViewHolder)convertView.getTag();
- }
- holder.carName.setText(car.getName());
- buildGroupsFlowLayout(holder.carGroups, car.getGroups());
- return convertView;
- }
- /**
- * Build FlowLayout
- */
- private void buildGroupsFlowLayout(FlowLayout flowLayout, List<CarGroup> groupsList) {
- flowLayout.removeAllViews();
- int i = 0;
- for(CarGroup group : groupsList) {
- View groupItemView = mInflater.inflate(R.layout.car_group_item, null);
- TextView lineView = (TextView)groupItemView.findViewById(R.id.car_group_item_goup_text);
- lineView.setText(group.getName());
- lineView.setTextColor(group.getColor());
- flowLayout.addView(groupItemView, i, new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT));
- i++;
- }
- }
- public static class ViewHolder {
- public TextView carName;
- public FlowLayout carGroups;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement