How to resolve the error "ArrayAdapter requires the resource ID to be a TextView"

0

I was trying to list all bluetooth devices in a list, but when I try to create an Arrayadapter the application hangs and this error

'

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        SetContentView(Resource.Layout.tela);

        BluetoothAdapter adaptador = BluetoothAdapter.DefaultAdapter; // procura o adap. bluetooth padrão
        ListView lista = FindViewById<ListView>(Resource.Id.list);

        if (adaptador == null)
        {
            Toast.MakeText(this, "Esse aparelho não tem bluetooth", ToastLength.Long).Show();
        }
        else {
            if (adaptador.IsEnabled == true)
            {
                ICollection<BluetoothDevice> aparelhos = adaptador.BondedDevices;
                BluetoothDevice[] apa = new BluetoothDevice[aparelhos.Count];

                ArrayAdapter<BluetoothDevice> adapconfig;
                ParcelUuid[] uuid = new ParcelUuid[aparelhos.Count];
                BluetoothSocket socket;
                int i = 0;


                foreach (BluetoothDevice aparelho in aparelhos)
                {
                    apa[i] = aparelho;
                    uuid = aparelho.GetUuids();
                    socket = aparelho.CreateRfcommSocketToServiceRecord(uuid[i].Uuid);
                    i++;

                }
                adapconfig = new ArrayAdapter<BluetoothDevice>(this, Resource.Layout.tela, Resource.Id.list,apa);   
                lista.Adapter = adapconfig; 
            }
            else{
                Toast.MakeText(this,"Ative o bluetooth para continuar",ToastLength.Long);

            }



        }
    }'
    
asked by anonymous 12.10.2016 / 16:06

1 answer

0

Try to use BluetoothAdapter.getDefaultAdapter(); E adaptador.getBondedDevices();

    
12.10.2016 / 20:02