我如何正确地从资源中获取整数?
How I could get integers from resources properly?
我正在努力从 Android 中的资源中获取结果。不知道是我做错了还是做不到。
我在 logcat 中得到了整数(调试因为我的代码不起作用)。它存储在一个向量中,我得到了一个 if 条件的数字,但它没有得到资源中声明的整数。
Log.d("Valor de int correcto",String.valueOf((int) puntuation.get(5)));
并且 Log cad 显示
D/Valor de int correcto: 2131230722
向量从……获取整数
puntuation.add(R.integer.c_1);
声明为:
<integer name="c_1">1</integer>
提前致谢!
尝试使用
puntuation.add(getResources().getInteger(R.integer.c_1));
我正在努力从 Android 中的资源中获取结果。不知道是我做错了还是做不到。
我在 logcat 中得到了整数(调试因为我的代码不起作用)。它存储在一个向量中,我得到了一个 if 条件的数字,但它没有得到资源中声明的整数。
Log.d("Valor de int correcto",String.valueOf((int) puntuation.get(5)));
并且 Log cad 显示
D/Valor de int correcto: 2131230722
向量从……获取整数
puntuation.add(R.integer.c_1);
声明为:
<integer name="c_1">1</integer>
提前致谢!
尝试使用
puntuation.add(getResources().getInteger(R.integer.c_1));