[英]Update TextView in Android with amount of bluetooth devices found via ListAdapter or BluetoothAdapter
I want to create a TextView
in an Android app which shows how many bluetooth devices are found and list them in the UI. 我想在Android应用程序中创建一个
TextView
,显示找到多少个蓝牙设备并在UI中列出它们。
Inside the MainActivity
(only acivity), there is an ArrayList
inside a private class ListAdapter extends BaseAdapter
. 在
MainActivity
内部(仅限acivity),私有类中有一个ArrayList
ListAdapter extends BaseAdapter
。 Besides in that class there is also a private BluetoothAdapter.LeScanCallback
with onLeScan
method that includes ListAdapter.notifyDataSetChanged()
. 除了该类之外,还有一个带有
onLeScan
方法的私有BluetoothAdapter.LeScanCallback
,其中包括ListAdapter.notifyDataSetChanged()
。 The ListAdapter
uses a listView
to bind the results of bluetooth scanning to the UI. ListAdapter
使用listView
将蓝牙扫描的结果绑定到UI。 The issue now is that I don't know how to create a trigger that sends the currently found/displayed (and constantly changing) amount of devices in a simple TextView
above (!) the ArrayList
and updates it every time the amount of devices in the list varies. 现在的问题是,我不知道如何创建一个发送设备的当前发现/显示(和不断变化)量的简单触发
TextView
以上(!)的ArrayList
,并在每一次更新IT设备的数量名单各不相同。
Do you have any suggestions? 你有什么建议吗? I have only found examples from different cases, and mostly with updating through buttons.
我只找到了不同情况下的例子,主要是通过按钮更新。
You should crate an listener
for when a new Bluetooth scan is done. 您应该为新的蓝牙扫描完成时
listener
一个listener
器。 That listener
should update the UI , TextView
. 该
listener
应该更新UI , TextView
。 Read more about Android Callbacks here. 在此处阅读有关Android回调的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.