我认为这会将资源中的两个数组绑定(bind)到一个数组中:
Resource res=getResources();
final int[] one_array=res.getIntArray(R.array.first_array) + res.getIntArray(R.array.second_array);
但是变量数组不能像下面这样声明:
The operator + is undefined for the argument type(s) int[], int[]
我还想将资源中的两个数组+一个数组绑定(bind)到一个数组中。在我看来,应该是:
Resource res=getResource();
final int[] one_array={ 1,2,3,4,5,res.getIntArray(R.array.first_array),res.getIntArray(R.array.second_array) };
但是变量数组不能像下面这样声明:
Multiple markers at this line
- Type mismatch: cannot convert from
int[] to int
如何实现通过绑定(bind)资源和普通数组中的两个数组来声明一个数组? 是否有其他/替代方法/解决方案来绑定(bind)数组?
最佳答案
final int[] one_array = ArrayUtils.addAll(res.getIntArray(R.array.first_array), res.getIntArray(R.array.second_array);
+
运算符将连接两个字符串。
关于java - 如何将资源数组和普通数组绑定(bind)到一个数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18524689/