Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- calorieDataController.returnDatabaseReference().addValueEventListener(new ValueEventListener() {
- @Override
- public void onDataChange(DataSnapshot dataSnapshot) {
- // This method is called once with the initial value and again whenever data at this location is updated.
- if(dataSnapshot.getValue(Integer.class) != null){
- Toast.makeText(Dashboard.this, String.valueOf(dataSnapshot.getValue()), Toast.LENGTH_SHORT).show();
- //If I change the value in setProgress to a static value such as 45, it displays correctly.
- ringProgressBar.setProgress((((Integer.parseInt(String.valueOf(dataSnapshot.getValue()))) /2500)*100));
- }else{
- }
- }
- @Override
- public void onCancelled(DatabaseError error) {
- // Failed to read value
- }
- });
- <ProgressBar
- android:id="@+id/ringProgress"
- style="?android:progressBarStyleHorizontal"
- android:layout_width="250dp"
- android:layout_height="250dp"
- android:layout_marginTop="50dp"
- android:progress="0"
- android:progressDrawable="@drawable/ringprogress"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="ring"
- android:innerRadius="100dp"
- android:thickness="20dp"
- android:useLevel="true">
- <solid android:color="@color/colorAccent"/>
- </shape>
Add Comment
Please, Sign In to add comment