Dear Ytai, Im trying to set Progress Bar for my Temperature Value Im not
sure how its done, heres my code:
class Looper extends BaseIOIOLooper {
public void setup() throws ConnectionLostException {
twi = ioio_.openTwiMaster(1, TwiMaster.Rate.RATE_100KHz, false);
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(),
"TMP102 Connected!", Toast.LENGTH_SHORT).show();
}
});
}
public void loop() throws ConnectionLostException, InterruptedException {
try {
twi.writeRead(address, false, request, request.length, response, response.
length);
/* Update UI */
updateViews(getTemperature());
* setProgressBar(); ???*
} catch (InterruptedException e) {
ioio_.disconnect();
} catch (ConnectionLostException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
}
}
// Get Temperature in C Method
public float getTemperature() throws Exception {
celcius = Temp.from(response[0]) << 8 | Temp.from(response[1]);
celcius >>=4;
return celcius / 16.f;
}
}
// Update TextView with Temperature Reading
private void updateViews(float f) {
final String str = String.format(Locale.UK, "%.1f", f);
runOnUiThread(new Runnable() {
@Override
public void run() {
tmpTextView.setText(str);
}
});
}
// Set Value to ProgressBar
private void setProgressBar(final int value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBarTemp.setProgress(value);
}
});
}
*My XML File for ProgressBar:*
<ProgressBar
android:id="@+id/progressBarTemp"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="250dp"
android:layout_height="273dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="false"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/circular_progressbar" />
*And my Circular progress Bar in Drawable Folder:*
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/progress">
<shape android:shape="ring"
android:innerRadiusRatio="4"
android:thicknessRatio="8.0">
<gradient
android:startColor="#287AA9"
android:centerColor="#FFCC00"
android:endColor="#ff0000"
android:type="sweep" />
</shape>
</item>
</layer-list>
--
You received this message because you are subscribed to the Google Groups
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.