我有一个列表视图。它工作正常。我想要的是为列表视图中的每一行添加一个复选框。那是我的代码:
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();
有没有一种简单的方法可以通过更改我的代码来做到这一点?