我正尝试创建一个图像按钮,当按下该按钮时,向用户呈现配对的蓝牙设备连接列表。寻找Android蓝牙配对设备
但是,在## 1, 处得到“设置无法解析为变量”,并且在## 2处出现“mArrayAdapber无法解析” (## 1和## 2不是代码...)
我使用了Android站点的代码,但在黑暗中,我发现自己处于黑暗中。
我会很感激一些指导...
//搜索
ImageButton bSearch = (ImageButton) findViewById(R.id.Search);
bSearch.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
##1Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
// Add the name and address to an array adapter to show in a ListView
##2mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
}
});
它看起来像您根据您的描述有语法错误。第一个看起来像是缺少Set类的导入,另一个是你没有定义mArrayAdapter。 – momo
嘿,你能给我们的设备中的蓝牙设备搜索完整的源代码。提前致谢。 – anddev