所以,如果它的值大于0,我需要将textView颜色更改为红色,如果它小于0,我需要将其更改为绿色,但是如果语句正确则我无法写入,因为textView是一个字符串,但我已将其更改为int。
textView.setText(textView + "");
if(textView > 0) {
textView.setTextColor(this.getResources().getColor(R.color.colorAccent));
}
else if (textView < 0){
textView.setTextColor(this.getResources().getColor(R.color.colorPrimary));
}
else {
textView.setTextColor(this.getResources().getColor(R.color.colorPrimaryDark));
}
答案 0 :(得分:0)
要使用String
内的TextView
(不是String
,而是View
),您首先需要.getText().toString()
访问String stringValue = textView.getText().toString();
int intValue = Integer.parseInt(stringValue);
//Now do your logic.
1}}。因此,如果您希望像整数一样使用textView的值,请执行以下操作:
String
如果您想再次将值设置为视图,请确保您传递的是[SCNTransaction begin];
[SCNTransaction setAnimationDuration:0];
...
[SCNTransaction commit];
而不是整数。