ArrayList add함수에 대해서
조회수 1578회
List<String> listItems = new ArrayList<String>();
for(BluetoothDevice device : mDevices) {
listItems.add(device:mDevices){
}
listItems.add("취소");
}
final CharSequence[] items = listItems.toArray(new CharSequence[listItems.size()]);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (item == mPairedDeviceCount) {
} else {
}
}
});
아두이노와 연결할려고 블루투스 API를 이용할려고 하는데 블루투스 디바이스 목록을 가져와서 페어링을 할려고 합니다. list.add(device:mDevices)에서 오류가 납니다. 오류 내용은 ';' expected, ')' expected unexpected token 오류가 나네요 여기서 뭐가 문제일까요?
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
요 블로그에서 보고 하신거 같은데, 제가 알기로
list.add(a : b) {}
이런 문법은 존재하지 않습니다.
아마 블로그 작성자분이 오타를 낸게 아닌가 싶구요.
// 페어링 된 블루투스 장치의 이름 목록 작성 List<String> listItems = new ArrayList<String>(); for (BluetoothDevice device : mDevices) { listItems.add(device); } listItems.add("취소"); // 취소 항목 추가
이렇게 해보세요.
댓글 입력