0
您好我创建customlistview第一次添加一个按钮我插入值为0.当我必须单击该添加按钮值是1更改database.Getting列值结果。当我们在android中添加数据库时,Customlistview改变了按钮?
注* 获得价值成果1个单元变更按钮或color.I我在baseadapter使用 *
这里我提到的示例代码也:
holder.btn_add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap.put("product", arrListproduct_name
.get(position).toString().trim());
hashMap.put(
"price",
getDoublePrecision(arrListproductprice
.get(position).toString().trim()));
hashMap.put("productID", arrlistproduct_id
.get(position).toString().trim());
hashMap.put("quantity", datavalue);
hashMap.put("resturantID",
category.dinein_restaurant_id);
hashMap.put("value", Str_value);
arrListproductdatabase.add(hashMap);
if (dataBase.ProductExist(
DatabaseHelper.TABLErestaurant,
arrlistproduct_id.get(position).toString()
.trim())) {
Toast.makeText(VegNonVegClass.this,
"Update successfully", Toast.LENGTH_LONG)
.show();
for (int i = 0; i < GetAllitemDetailsItem.size(); i++) {
dataBase.updateData1(
GetAllitemDetailsItem.get(i).get("id"),
DatabaseHelper.TABLErestaurant, "1");
}
} else {
dataBase.insertData(DatabaseHelper.TABLErestaurant,
arrListproductdatabase);
arrListproductdatabase.clear();
Toast.makeText(VegNonVegClass.this,
"Add successfully", Toast.LENGTH_LONG)
.show();
// arrListproductdatabase.remove(position);
// notifyDataSetChanged();
ArrayList<String> selectedno = dataBase
.getselectedTrue();
for (String s : selectedno) {
if (s.equalsIgnoreCase("1")) {
holder.btn_add
.setBackgroundResource(R.drawable.checkout);
}
}
}
if (listener != null) {
listener.totalAmount(String.valueOf(Str_subtotal));
}
}
});
问题按钮被改变,但列表视图刷新意味着自动更改上一个按钮请给我解决方案