我有一个列表视图。它工作正常。 我想要的是为列表视图中的每一行添加一个复选框。 多数民众赞成我的代码:
public class List extends ListActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
while(true){
if (mBluetoothAdapter.isEnabled()) {
break;
}
}
Toast.makeText(getApplicationContext(), "Bluetooth turned on", Toast.LENGTH_SHORT).show();
}
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
ArrayList<String> arrayOfBluetoothDevicesNames = new ArrayList<String>();
for(BluetoothDevice bt : pairedDevices) {
arrayOfBluetoothDevicesNames.add(bt.getName());
}
setListAdapter(new ArrayAdapter<String>(this, R.layout.list, arrayOfBluetoothDevicesNames));
ListView listViewOfBluetooth = getListView();
通过更改我的代码是一种简单的方法吗?