How can i add the value of n with 2 ?, ie., n+2
the textview output should be 4 .
int n=2;
private void tvm() {
if (n<=maxCount) {
n++;
textview.setText("Counter:"+ n+2);
}
Just you need to give the priority by giving brackets like the same shown in the above answers.Hope now it will be working fine.
tv.setText("Text you enter: "+ (a + b));
output: "Text you enter: c
"
where c =a + b
int n=2;
private void tvm() {
if (n<=maxCount) {
textview.setText("Counter:"+ String.valueOf( n+2));
n++;
}
将您的代码更改为
textview.setText("Counter:"+ (n+2));
If you want output as 4 then first you need to set value to textView then incrment n value.
if (n<=maxCount)
{
text.setText("Counter:"+ (n+2));
n++;
}
Output : Counter:4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.