我是Android和java编程的新手。我想逐字符地读取我的字符串..以这种方式将第一个字符设置为某个文本视图,将第二个字符设置为其他文本视图..我的字符串不要包含两个以上的字符。我尝试了charAT()方法,但没有结果请查看代码。
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
val1 = Integer.parseInt(String.valueOf(quotient3.getText()));
val2 = Integer.parseInt(String.valueOf(divisor.getText()));
result = val1 * val2;
val = Integer.toString(result);
if(val.length()==1){
aftersub2dividend2.setText(val.charAt(0)); //here is the issue
aftersub2dividend1.setText(val.charAt(1)); //here is the issue
}
else {
aftersub2dividend1.setText(val.charAt(0)); //here is the issue
aftersub2dividend2.setText(val.charAt(1)); //here is the issue
}
}
},3000);
答案 0 :(得分:0)
aftersub2dividend1.setText(String.valueOf(val.charAt(0)));