【发布时间】:2014-10-13 20:00:40
【问题描述】:
我正在研究如何将数组列表添加到警报对话框。当我调用alertdialog.setItems 时,我收到了无法解决此方法的错误。有人可以看看并引导我解决这个问题吗?提前致谢。
代码:
if(arrayListBluetoothDevices.size()<1) // this checks if the size of bluetooth device is 0,then add the
{ // device to the arraylist.
detectedAdapter.add(device.getName()+"\n"+device.getAddress());
arrayListBluetoothDevices.add(device);
final CharSequence[] items2 = {"This is here just to figure out how to get setItems to call properly"};
AlertDialog ad = new AlertDialog.Builder(context).create();
ad.setTitle("Pop up the found devices here");
ad.setItems(items2, null);
ad.setButton("Somehow set this to work when the arraylist is pressed", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Do stuff here for OK The bottom button
}
});
ad.show();
detectedAdapter.notifyDataSetChanged();
}
【问题讨论】:
-
请发布堆栈跟踪
-
这是我得到的编译错误:错误:(332, 23) 错误: 找不到符号方法 setItems(CharSequence[],
)。这就是你要找的东西吗,我无法进入应用程序进行堆栈跟踪。
标签: java android arraylist android-arrayadapter android-alertdialog