开发者

On checking a check box from a row in list view few other check boxes are also getting selected. (In android)

On checking a check box from a row in list view few other check boxes are also getting selected. (In android). Does anybody knows that why this problem is occurring? Here is my source code:

            dbHelper db1 = new dbHelper(WaterPopup.this);

    waterList = new ArrayList<HashMap<String, Object>>();

    map1 = new HashMap<String, Object>();

    Cursor c1 = db1.getMenuDetailsData(SubMenuID);
    c1.moveToFirst();
    while (c1.isAfterLast() == false) {

        if (c1.getString(3).substring(0).equals("I")) {
            map1.put("WaterOptionID", c1.getString(5).substring(0)) ;
              map1.put("CheckBox",cb);
              map1.put("WaterOptionName", c1.getString(0).substring(0));
              map1.put("MinusImg",R.drawable.minus_30+"");
              map1.put("Quantity","1");
              map1.put("PlusImg",R.drawable.plus_30+"");
              map1.put("Currency","$");
              map1.put("Price", c1.getString(2).substring(0));
              map1.put("OrderStatusImg",R.drawable.round_25+"");

          开发者_如何学运维  waterList.add(map1);
            map1 = new HashMap<String, Object>();
        }

        c1.moveToNext();
    }
    c1.close(); 


        mSchedule = new SimpleAdapter(WaterPopup.this, waterList, R.layout.waterlistitem,
                new String[] {"WaterOptionID","CheckBox", "WaterOptionName", "MinusImg", "Quantity","PlusImg","Currency", "Price", "OrderStatusImg"}, 
                   new int[] {R.id.wateroptionID_tv,R.id.orderWater_cb, R.id.wateroptionName_tv, R.id.minussign_btn, R.id.Qty_tv, R.id.plusimage_btn,R.id.currency_tv,R.id.price_tv,R.id.orderStatus_btn});
        OrderWaterItem.setAdapter(mSchedule);


You have to override the adapter. It is not hard. Look here:

http://www.geekmind.net/2009/11/android-custom-list-item-with-nested.html

and here:

Android: ListView elements with multiple clickable buttons


SimpleAdapter only support TextViews:

Description of the 'to'-parameter in the constructor:

"The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜