Manu
Manu

Reputation: 59

How I could get integers from resources properly?

I'm strugling with getting results from the resourses in Android. I don't know if I'm doing wrong or if it can't be done.

I get the int in the logcat(debuggin because my code doesn't work). It is stored in a vector, I get that number for an if condition but it doesn't get the declared integer in resources.

        Log.d("Valor de int correcto",String.valueOf((int) puntuation.get(5)));

And the Log cad shows

D/Valor de int correcto: 2131230722

The vector gets the int from...

puntuation.add(R.integer.c_1);

which is declared as:

<integer name="c_1">1</integer>

Thanks in advance!

Upvotes: 0

Views: 63

Answers (1)

Jyoti JK
Jyoti JK

Reputation: 2171

Try to use

puntuation.add(getResources().getInteger(R.integer.c_1));

Upvotes: 4

Related Questions