| |
---|
| | import android.view.ViewGroup; |
---|
| | import android.widget.ArrayAdapter; |
---|
| | import android.widget.TextView; |
---|
| | |
---|
| | import org.ntlab.irisclient.models.Member; |
---|
| | import java.util.List; |
---|
| | |
---|
| | public class MemberListAdapter extends ArrayAdapter<String> { |
---|
| | |
---|
| | private LayoutInflater mLayoutInflater; |
---|
| | static class ViewHolder { |
---|
| | TextView textView; |
---|
| | } |
---|
| | private LayoutInflater inflater; |
---|
| | private final int itemLayoutId; |
---|
| | private final List<String> memberList; |
---|
| | |
---|
| | final int redColor = Color.rgb(172, 32,32); |
---|
| | final int blueColor = Color.rgb(32, 32, 172); |
---|
| | final int grayColor = Color.rgb(172, 172, 172); |
---|
| | |
---|
| | public MemberListAdapter(Context context) { |
---|
| | public MemberListAdapter(Context context, int itemLayoutId, |
---|
| | List<String> members) { |
---|
| | super(context, 0); |
---|
| | mLayoutInflater = LayoutInflater.from(context); |
---|
| | this.inflater = (LayoutInflater) context.getSystemService( |
---|
| | Context.LAYOUT_INFLATER_SERVICE); |
---|
| | this.itemLayoutId = itemLayoutId; |
---|
| | this.memberList = members; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public View getView(int position, View convertView, ViewGroup parent) { |
---|
| | ViewHolder holder; |
---|
| | |
---|
| | if (convertView == null) { |
---|
| | // activity_member_room.xml に member_list_layout.xml を inflate して convertView とする |
---|
| | convertView = inflater.inflate(itemLayoutId, parent, false); |
---|
| | |
---|
| | // ViewHolder を生成 |
---|
| | holder = new ViewHolder(); |
---|
| | holder.textView = convertView.findViewById(R.id.textView); |
---|
| | |
---|
| | convertView.setTag(holder); |
---|
| | |
---|
| | if (position == 0) { |
---|
| | // 背景色を変える |
---|
| | convertView.setBackgroundColor(Color.rgb(255, 127, 255)); |
---|
| | }else{ |
---|
| | convertView.setBackgroundColor(Color.rgb(0, 125, 0)); |
---|
| | } |
---|
| | } |
---|
| | else { |
---|
| | holder = (ViewHolder) convertView.getTag(); |
---|
| | } |
---|
| | |
---|
| | // 現在の position にあるファイル名リストを holder の textView にセット |
---|
| | holder.textView.setText(memberList.get(position)); |
---|
| | |
---|
| | return convertView; |
---|
| | /* |
---|
| | View root = mLayoutInflater.inflate(R.layout.activity_member_room, null); |
---|
| | |
---|
| | String item = getItem(position); |
---|
| | |
---|
| | root.setBackgroundColor(redColor); |
---|
| | */ |
---|
| | |
---|
| | } |
---|
| | |
---|
| | return root; |
---|
| | @Override |
---|
| | public int getCount() { |
---|
| | // texts 配列の要素数 |
---|
| | return memberList.size(); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public String getItem(int position) { |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public long getItemId(int position) { |
---|
| | return 0; |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
RoomViewModelをTimerViewModelを継承する形に更新しました 。
その他途中ですがRoomActivityのリストのレイアウトを変更するクラスを追加しています。
今のところ指定の背景色が変わります
RoomViewModelの更新。MemberListのレイアウトを変えるクラスの追加、更新。
0c1e805
intomaster
fromRoomViewModel
on 29 Sep 2022