Reputation: 1747
I have a humidity sensor that broadcasts the last ten values as a single array after a fixed time interval. I want to display these values in ten Textview
's.
My current code displays all the values in a single TextView
, how can I modify this?
How could it possible?
@Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
if (BleUuid.READ_SENSOR
.equalsIgnoreCase(characteristic.getUuid().toString())) {
final String values = characteristic.getStringValue(0);
byte[] bytes =values.getBytes();
final String value = new String(bytes);
runOnUiThread(new Runnable() {
public void run() {
statuslv.setText(value);
setProgressBarIndeterminateVisibility(false);
}
});
Upvotes: 0
Views: 452
Reputation: 1296
Split up the String you receive.
Depending on the format, you should be able to use something like this
String[] parts = string.split(","); //this should use the character(s) which separate your results
If you really want to show the results in 10 different TextViews, then you can do
textView1.setText(parts[0]);
textView2.setText(parts[1]);
//...
You could also put the results in a ListView.
Upvotes: 1