Forcer une expandableListView à se redessiner
Bonjour,
j'ai une expandablelisView avec pour chaque group une checkbox et chaque child une checkbox également.
Lors du check d'un group toutes les checkbox du child sont checkés automatiquement. Je n'ai aucun probléme pour que l'état des checkboxs soit mis à jour.
Par contre j'aimerai forcer l'expandableListView à se redessiner lors de ce changement...et je n'ai aucune idée de comment procéder.
Voici les extraits de code produits (qui seront sans doute plus parlant) :
ici je gére le onclick du group :
Code:
1 2 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
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
GroupViewHolder gholder;
final TypeVehicule type=(TypeVehicule) getGroup(groupPosition);
if (convertView==null)
{
gholder=new GroupViewHolder();
convertView = inflater.inflate(R.layout.listevehicule_type,null);
gholder.textViewGroup=(TextView)convertView.findViewById(R.id.LV_textType);
gholder.checkType=(CheckBox)convertView.findViewById(R.id.LV_CheckType);
gholder.checkType.setTag(groupPosition);
gholder.imgType=(ImageView)convertView.findViewById(R.id.LV_ImageType);
convertView.setTag(gholder);
}
else
{
gholder = (GroupViewHolder)convertView.getTag();
}
gholder.textViewGroup.setText(type.getType());
if (type.getColor()==-1)
{
int color;
Random rnd = new Random();
color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
type.setColor(color);
}
gholder.imgType.setBackgroundColor(type.getColor());
gholder.checkType.setChecked(type.isIschecked());
gholder.checkType.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
type.setIschecked(((CheckBox) v).isChecked());
for (Vehicule _v : type.getListeVehicules())
{
_v.setIschecked(type.isIschecked());
}
}
});
gholder.checkType.setChecked(type.isIschecked());
// ici je voudrais dire a l'Expandable listView de se redessiner.
return convertView;
} |
et le code du onCreate de l'activty Concernée :
Code:
1 2 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
|
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(net.ornicar.ornimobile.R.layout.listevehicule);
listView_Vehic = (ExpandableListView)findViewById(R.id.ListeVehicules);
// ici pour l'instant on rempli en dur en attendant l'implementation de la couche metier..
for (int i=1; i<10;i++)
{
TypeVehicule type = new TypeVehicule("Type " + i);
ArrayList<Vehicule> oListVeh = new ArrayList<Vehicule>();
for (int j=0;j<10;j++)
{
oListVeh.add(new Vehicule(type, "Veh N°"+j+"-"+i));
}
type.setListVehicule(oListVeh);
oListType .add(type);
}
ListeVehiculesAdapter adapter = new ListeVehiculesAdapter(this, oListType,true);
listView_Vehic.setAdapter(adapter);
this.registerForContextMenu(listView_Vehic);
listView_Vehic.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Toast.makeText(getApplicationContext(), oListType.get(groupPosition).getListeVehicules().get(childPosition).getNom()+" Clicked!!", 4000).show();
return true;
}
});
} |
Merci d'avance si l'un d'entre vous peut m'aiguiller...