java - Override toString() method of final BluetoothDevice class -


in android app have listactivity displays bluetooth devices. have arraylist<bluetoothdevice> , arrayadapter<bluetoothdevice>. works there 1 problem. each bluetoothdevice displayed mac address in list need display name.

as know adapter calls tostring method on each object. bluetoothdevice returns mac address if call tostring on it. solution override tostring , return name instead of address. bluetoothdevice final class not able override it!

any ideas how force bluetooth device return name instead address? tostring?

as mentioned in comment extend arrayadapter , use method instead of tostring method.

for example so:

public class youradapter extends arrayadapter<bluetoothdevice> {    arraylist<bluetoothdevice> devices;    //other stuff  @override  public view getview(int position, view convertview, viewgroup parent) {    //get view , textview show name of device    textview.settext(devices.get(position).getname());    return view;  } } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -