这就是我使用占位符将文本设置为 TextView
的方式。
myTextView.setText(String.format(getResources().getString(R.string.total_savings), totalSavings));
这是字符串资源值
<string name="total_savings">Total Savings: %1$d</string>
现在,我需要从 TextView
中获取 %1$d
的值。
我的问题是,如何使用 getText()
方法从 TextView
获取十进制整数值。
最佳答案
在 String.xml 文件中设置此文本
<string name="total_savings">Total Saving : %1$d</string>
在Java文件中设置文本使用
myTextView.setText(getResources().getString(R.string.total_savings));
获取textview的值使用
String output = myTextView.getText().toString();
关于android - 如何从占位符设置的 Textview 中获取 Int 或 String 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44015821/