[英]Android Bluetooth: Update connection state dynamically for single row in listview
I would like to create a listview with all bluetooth devices scanned. 我想创建一个扫描了所有蓝牙设备的列表视图。 Each row will contain a connection state of text and clicking it will make the device connect to remote device.
每行将包含文本的连接状态,单击该行将使设备连接到远程设备。 How could I update only the single row of remote device being connected in listview so the connection state will keep changing: disconnected -> connecting -> connected for example?
我如何只更新列表视图中正在连接的远程设备的单行,以便连接状态将不断变化:例如,断开连接->连接->已连接?
You can take row from ListView at required position and update: 您可以在所需位置从ListView中获取行并进行更新:
private void refreshConnectionState(int rowIndex, String newConnectionState){
View row = devicesListView.getChildAt(rowIndex);
if(row == null) return;
TextView stateTextView = (TextView )row.findViewById(R.id.state_text_view);
stateTextView.setText(newConnectionState);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.