title: Listing available Bluetoothdevices in ListView but ListView isn't shown
body: <p>I want to create a app that can send data with Bluetooth to another device. First I made a Button to turn Bluetooth on and off. That works smoothly! Now I included a ListView that should list available yet unpaired devices, but the ListView is not showing. I searched for a solution but I coulnd't find anything. I don't get any Event Log and I don't know what I should do. I tried many different things but in the end my app just kept crashing. Here is my code:</p>
  
  <pre><code>&lt;Button
      android:text="On/Off"
      android:id="@+id/btnONOFF"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      tools:ignore="MissingConstraints" /&gt;
  
  &lt;ListView
      android:id="@+id/lvNewDevices"
      android:layout_width="162dp"
      android:layout_height="196dp"
      app:layout_constraintTop_toBottomOf="@id/btnONOFF"
      tools:layout_editor_absoluteX="3dp"
      tools:layout_editor_absoluteY="96dp"
      tools:ignore="MissingConstraints" /&gt;
  </code></pre>
  
  <p>The MainActivity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener{
  private static final String TAG = "Main Activity";
  
  BluetoothAdapter mBluetoothAdapter;
  
  public ArrayList&lt;BluetoothDevice&gt; mBTDevices = new ArrayList&lt;&gt;();       //hold BluetoothDevices that are discovered
  public DeviceListAdapter mDeviceListAdapter;
  public ListView lvNewDevices;
  
  private BroadcastReceiver mBroadcastReceiver3 = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          final String action = intent.getAction();
          Log.d(TAG, "onReceive: ACTION FOUND.");
  
          if(action.equals(BluetoothDevice.ACTION_FOUND)){
              BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);   //throws an parcelable extra device in the former device
              mBTDevices.add(device);     //stores the new device
              Log.d(TAG, "onReceive: " + device.getName()+ ": " + device.getAddress());
              mDeviceListAdapter = new DeviceListAdapter(context, R.layout.device_adapter_view, mBTDevices);   //attach DeviceList to DeviceListAdapter
              lvNewDevices.setAdapter(mDeviceListAdapter);        //set the List to AdapterList
              //remember device_adapter_view.xml in res -&gt; layout!
          }
      }
  };
  
  protected void onDestroy(){
      Log.d(TAG, "onDestroy: called");
      super.onDestroy();
      unregisterReceiver(mBroadcastReceiver3);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button btnONOFF = (Button) findViewById(R.id.btnONOFF);
      lvNewDevices = (ListView) findViewById(R.id.lvNewDevices);
      mBTDevices = new ArrayList&lt;&gt;();
  
      mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  
      lvNewDevices.setOnItemClickListener(MainActivity.this);
  
      btnONOFF.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Log.d(TAG, "onClick: enabling/disabling bluetooth.");       //tell when Button is clicked
              enableDisableBT();
          }
      });
  }
  
  /* if Bluetooth is enabled and Button is clicked, Bluetooth will turn off
     if Bluetooth is not enabled and Button is clicked, Bluetooth will turn on
   */
  public void enableDisableBT() {
  
      if (mBluetoothAdapter == null) {      //means device has no Bluetooth Adapter
          Log.d(TAG, "enableDisableBT: Does not have BT capabilities.");
          finish();
      }
      if (!mBluetoothAdapter.isEnabled()) {     //if Bluetooth is not enabled
          Log.d(TAG, "enableDisableBT: enabling BT.");
          Intent enableBTIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
          startActivity(enableBTIntent);
      }
      if (mBluetoothAdapter.isEnabled()) {      //if Bluetooth is enabled
          Log.d(TAG, "enableDisableBT: disabling BT.");
          mBluetoothAdapter.disable();        //disable Bluetooth
      }
  }
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
      //first cancel discovery because it's very memory intensive
      mBluetoothAdapter.cancelDiscovery();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The DeviceListAdapter class</p>
  
  <pre><code>public class DeviceListAdapter extends ArrayAdapter&lt;BluetoothDevice&gt; {
  
  private LayoutInflater mLayoutInflater;
  private ArrayList&lt;BluetoothDevice&gt; mDevices;
  private int mViewResourceId;
  
  public DeviceListAdapter(Context context, int tvResourceId, ArrayList&lt;BluetoothDevice&gt; devices){
      super(context, tvResourceId, devices);
      this.mDevices = devices;
      mLayoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      mViewResourceId = tvResourceId;
  }
  
  public View getView(int position, View convertView, ViewGroup parent){
      convertView = mLayoutInflater.inflate(mViewResourceId, null);
      BluetoothDevice device = mDevices.get(position);
  
      if(device != null){
          TextView deviceName = (TextView)convertView.findViewById(R.id.tvDeviceName);
          TextView deviceAdress = (TextView)convertView.findViewById(R.id.tvDeviceAddress);
  
          if(deviceName != null){
              deviceName.setText(device.getName());
          }
          if(deviceAdress != null){
              deviceAdress.setText(device.getAddress());
          }
      }
      return convertView;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I made a BluetoothChat Tutorial because I never programmed Bluetooth before. I hope you can help me!</p>