点击加号和减号去加减数据
//减号点击
tv_jianhao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String countString = tv_count.getText().toString().trim();
if (countString.equals("0")) {
return;
}
int count = Integer.parseInt(countString) - One;
tv_count.setText("" + count);
} catch (Exception e) {
e.printStackTrace();
}
}
});
//加号点击
tv_jiahao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String countString = tv_count.getText().toString().trim();
int count = Integer.parseInt(countString) + One;
tv_count.setText("" + count);
} catch (Exception e) {
e.printStackTrace();
}
}
});