0

In my code I have an integer xml file and I want to use the values inside in my code.

But when I show them in my textview instead of 0 I get 2131361797.

Here is my xml:

<resources>
    <integer name="zero">0</integer>
    <integer name="minimum_number">0</integer>
    <integer name="maximum_number">12</integer>
</resources>

And here is my code:

correctValue.setText(R.integer.zero + "");
incorrectValue.setText(R.integer.maximum_number + "");

I have also tried String.valueOf(R.integer.zero);, but that also gave the same results.

How can I resolve this?

1 Answer 1

2

Use getResources().getInteger method to get int value from integers.xml :

correctValue.setText(String.valueOf(
            getResources().getInteger(R.integer.zero)));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.