-1

i have a list view. it works fine. what i want is to add a checkbox for every line in the list view. thats my code:

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();

is ther a simple way of doing it by changing my code?

roiberg
  • 13,629
  • 12
  • 60
  • 91

1 Answers1

1

There are many solution for multiple selection in listview..

Solution 1

Solution 2

Solution 3

Community
  • 1
  • 1
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
  • thanks, but i was wondering if there is a way to modify my code and get the same result... – roiberg May 30 '12 at 06:54
  • 1
    I think you have to use BaseAdapter instead of ArrayAdapter for multiple selection on listview so you have to change yr code – Niranj Patel May 30 '12 at 07:01