| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 
 | class MyAdapter extends BaseAdapter {
 
    private Activity mContext;
    private String[] noms;
    private int taille;
    private int[] tColor=  {Color.rgb(0,171,169),Color.rgb(255,0,151), Color.rgb(162,0,255),
                            Color.rgb(27,161,226),Color.rgb(240,150,9),Color.rgb(204,236,117),
                            Color.rgb(255,247,151),Color.rgb(203,44,49),Color.rgb(133,189,222),
                            Color.rgb(0,119,119),Color.rgb(248,185,207),Color.rgb(255,173,965)};
 
    public MyAdapter( Activity activity, int nb_joueurs) {
       this.mContext = activity;
       this.taille= nb_joueurs;
       this.noms= new String [nb_joueurs];
        for(int i=0 ; i<nb_joueurs; i++) {
            noms[i] = activity.getString(R.string.joueur) + " " + (i+1);
        }
    }
 
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return taille;
    }
 
    @Override
    public Joueur getItem(int position) {
        Joueur joueur = new Joueur(noms[position], tColor[position]);
        return joueur;
    }
 
    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    class Holder {
        EditText mEditText;
        Button bColor;
    }
 
    class ColorListener implements View.OnClickListener {
 
        @Override
        public void onClick(View v) {
            // il faudrait ouvrir la boite de dialogue ici...
 
        }
    }
 
    ColorListener ColorListener = new ColorListener();
 
 
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
 
        // TODO Auto-generated method stub
        final Holder holder;
 
        if (convertView == null) {
            holder = new Holder();
            LayoutInflater inflater = mContext.getLayoutInflater();
            convertView = inflater.inflate(R.layout.noms_joueurs_layout, null);
            holder.mEditText = (EditText) convertView
                    .findViewById(R.id.mEditText);
 
            holder.bColor =(Button) convertView.findViewById(R.id.bColor);
            holder.bColor.setBackgroundColor(tColor[position]);
            holder.bColor.setOnClickListener( ColorListener);
 
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
 
        holder.mEditText.setText(noms[position]);
//        holder.mEditText.addTextChangedListener(new TextWatcher() {
//
//            String oldTexte = holder.mEditText.getText().toString();
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
//                 noms[position] = s.toString();
//
//
//            }
//        });
        return convertView;
    }
} | 
Partager