【问题标题】:What is the code to display an integer value in the xml?在 xml 中显示整数值的代码是什么?
【发布时间】:2011-12-10 13:10:21
【问题描述】:

我想显示一个用户将在 XML 中定义的整数。

    TextView Years = (TextView) findViewById(R.id.Years);
    Years.setText(Age);     

我知道这是对的,但我不知道在 XML 中放入什么来显示整数。 谢谢。

【问题讨论】:

    标签: java android xml textview int


    【解决方案1】:

    您将字符串放入 xml。如果您想将该字符串用作整数。你用线

    int number = Integer.parseInt(stringNumber);
    

    【讨论】:

    • 字符串下的值文件中是否有任何内容?您在 XML 中添加了什么?我无法获取使用新字符串设置 R 文件的代码。
    • 您是否提到了 values 文件夹中的 strings.xml?如果不放你的xml。 textview 可以获取资源id Years.setText(R.string.yourtext);
    • 是的,但我也无法让 R 文件中包含字符串。
    猜你喜欢
    • 2019-01-27
    • 2022-01-13
    • 2023-01-27
    • 1970-01-01
    • 1970-01-01
    • 2020-12-14
    • 2014-04-22
    • 1970-01-01
    • 2016-05-02
    相关资源
    最近更新 更多