I want to change my quantity textview to reflect the quantity of a particular item. But on clicking the add and sub buttons, the setText() function does not seem to work. Here i
You have to just call notifyDataSetChanged(); after add and sub button click code.
For Add
add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
quant[position]=quant[position]+1;
count1 +=1;
//holder.number.setText(Integer.toString(quant[position]));
holder.number.setText(count1.toString());
Toast.makeText(context, Integer.toString(quant[position]), Toast.LENGTH_SHORT).show();
Log.d("Quantity",Integer.toString(quant[position]));
positiveNumbers.put(holder.uniqueKey,count); //Key -> String.valueOf(position) and Value -> int count
notifyDataSetChanged();
}
});
For Sub
sub.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
quant[position]--;
Toast.makeText(context, Integer.toString(quant[position]), Toast.LENGTH_SHORT).show();
holder.number.setText(Integer.toString(quant[position]));
positiveNumbers.put(holder.uniqueKey,count); //Key -> String.valueOf(position) and Value -> int count
notifyDataSetChanged();
}
});
Hope it's help !!