【发布时间】:2021-05-24 16:04:08
【问题描述】:
我想在 android 中跟踪编辑文本的值,我使用的是调试模式。
这是一段代码,我从用户的输入中检索数据,我想在调试器中看到它。
EditText personName=findViewById(R.id.editTextTextPersonName2);
EditText number=findViewById(R.id.editTextNumber);
Intent sendBack=new Intent();
String sentName=personName.toString();
Integer a=Integer.parseInt(number.getText().toString());
sendBack.putExtra("name", sentName);
setResult(RESULT_OK, sendBack);
Activity2.this.finish();
但是,我注意到由整数(Number)返回的值显示在调试器中,而字符串(plainText)值不显示。
我希望能够看到字符串的值,就像屏幕截图中显示的整数一样。
【问题讨论】:
-
也许你想做
String sentName=personName.getText().toString();而不是String sentName=personName.toString(); -
我已经添加了 getText(),现在我可以在调试器中可视化来自用户的哪些数据,非常感谢你。