简体   繁体   English

动态文字栏位-Android

[英]Dynamic Text Field - Android

I'm trying to create a dynamic text field that will take multiple fields of user input during a single activity, do a calculation in the java file, and then display the resulting value within the SAME activity in a text field. 我正在尝试创建一个动态文本字段,该文本字段将在单个活动期间接受用户输入的多个字段,在Java文件中进行计算,然后在文本字段中的SAME活动中显示结果值。

Is there any way of doing this? 有什么办法吗? I just figured out that I can't edit strings.xml dynamically, so are there any structures I can use that will allow me to constantly change the values? 我只是发现我不能动态地编辑strings.xml,所以有什么可以使用的结构可以让我不断地更改值?

Thanks all. 谢谢大家

This will be pretty straight forward: 这将很简单:

String yourTextValue = "text";
TextView myTextView = (TextView) findViewById(R.id.textView1);
myTextView.setText(yourTextValue);

Just call setText() with your String value (whatever it may be) each time you want to change the value of your TextView. 每当您想更改TextView的值时,只需使用您的String值(无论它是多少)调用setText()即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM