diff --git a/app/src/main/java/org/ntlab/irisclient/MemberListAdapter.java b/app/src/main/java/org/ntlab/irisclient/MemberListAdapter.java index 2a5a125..95078ed 100644 --- a/app/src/main/java/org/ntlab/irisclient/MemberListAdapter.java +++ b/app/src/main/java/org/ntlab/irisclient/MemberListAdapter.java @@ -10,6 +10,7 @@ import org.ntlab.irisclient.models.Member; +import java.util.ArrayList; import java.util.List; public class MemberListAdapter extends ArrayAdapter { @@ -21,6 +22,9 @@ private final int itemLayoutId; private final List memberList; private final List dcList; + private List redTeam = new ArrayList<>(); + private List blueTeam = new ArrayList<>(); + private List grayTeam = new ArrayList<>(); final int redColor = Color.rgb(172, 32,32); final int blueColor = Color.rgb(32, 32, 172); @@ -51,21 +55,30 @@ convertView.setTag(holder); + // 背景色を変える convertView.setBackgroundColor(grayColor); - /*for(int i = 0 ; i < dcList.size();i++){ + redTeam.clear(); + blueTeam.clear(); + grayTeam.clear(); + for(int i = 0 ; i < dcList.size();i++){ if(dcList.get(i).getBelongs().equals("r")) { - convertView.setBackgroundColor(redColor); + redTeam.add(i); + }else if(dcList.get(i).getBelongs().equals("b")) { + blueTeam.add(i); + }else{ + grayTeam.add(i); } - }*/ + } + if (redTeam.contains(position)) { + convertView.setBackgroundColor(redColor); + }else if(blueTeam.contains(position)){ + convertView.setBackgroundColor(blueColor); + } else{ + convertView.setBackgroundColor(grayColor); + } - /*if (position == 0) { - // 背景色を変える - convertView.setBackgroundColor(Color.rgb(255, 127, 255)); - }else{ - convertView.setBackgroundColor(Color.rgb(0, 125, 0)); - }*/ } else { holder = (ViewHolder) convertView.getTag();