整数ArrayList上的TextUtils.join

use*_*345 3 java android arraylist

我有3个布尔值表示是否应该将int添加到列表中,然后我想TextUtils.join()在此列表中使用.

我该怎么办?

ArrayList<Integer> types = new ArrayList<Integer>();

if (m_bWithA) {
   types.add(this.TYPE_A); //TYPE_A is an int
}
if (m_bWithB) {
   types.add(this.TYPE_B); 
}
if (m_bWithC) {
   types.add(this.TYPE_C); 
}

TextUtils.join("|", types);
Run Code Online (Sandbox Code Playgroud)

但它说,我们只能使用TextUtils.join()Object[].

我应该使用其他功能还是不同类型的对象?

Ale*_*exR 6

使用 TextUtils.join(types.toArray())