Android 在复选框事件上重新绘制expandableListView

Android 在复选框事件上重新绘制expandableListView,android,expandablelistview,Android,Expandablelistview,我有一个expandablelistview,其中有一个按组的复选框和一个按子项的复选框。 当组被选中/取消选中时,所有子项都被选中/取消选中。我保留此复选框的状态没有问题,但我想强制可扩展列表视图重新绘制,以立即显示所有子项复选框被选中或取消选中。 我搜索了几个小时,没有找到解决办法。 如果有人能向我解释我们解决这个问题的方法,我将非常高兴 下面是我在expandableListAdapter中管理复选框更改的代码: public View getGroupView(int group

我有一个expandablelistview,其中有一个按组的复选框和一个按子项的复选框。 当组被选中/取消选中时,所有子项都被选中/取消选中。我保留此复选框的状态没有问题,但我想强制可扩展列表视图重新绘制,以立即显示所有子项复选框被选中或取消选中。 我搜索了几个小时,没有找到解决办法。 如果有人能向我解释我们解决这个问题的方法,我将非常高兴

下面是我在expandableListAdapter中管理复选框更改的代码:

    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());
      //
    return convertView;
}
以及onCreate的代码:

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;
        }
    });

}
创建时受保护的void(Bundle savedInstanceState)
{
//TODO自动生成的方法存根
super.onCreate(savedInstanceState);
setContentView(net.ornicar.ornimobile.R.layout.listVehicle);
listView_Vehicle=(可扩展listView)findViewById(R.id.ListVehicles);
//我要把速溶酒倒在服务员的身上。。

对于(int i=1;i要强制任何(可扩展的)ListView重画,您可以在视图使用的适配器上调用。这将强制重画屏幕上可见的任何内容。这意味着您的适配器必须扩展或。

谢谢…我尝试调用此方法..但不是在正确的位置…从onclick调用它非常有效!!!