2017-02-18 3 views
0

Ich versuche, von unbestimmten zu bestimmten horizontalen Fortschrittsbalken zu ändern, aber Determinte Fortschrittsbalken funktioniert nicht, wo unbestimmt funktioniert so gut.Android Horizontal bestimmte ProgressBar läuft nicht

Bestimmt erscheint eine aber keine Bewegung. bitte hilf mir.

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/check" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
    <ProgressBar 
    android:id="@+id/my_progressBar" 
    style="@style/Widget.AppCompat.ProgressBar.Horizontal" 
    android:indeterminate="false" 
    android:max="100" 
    android:progress="10"/> 
    </LinearLayout> 
    </android.support.design.widget.CoordinatorLayout> 

und ich fügte folgend in MainActivity.java:

ProgressBar progressBar = (ProgressBar) findViewById(R.id.my_progressBar); 
progressBar.setProgress(20); 
+0

Der Fortschritt beginnt bei 20 und erhöht sich nicht? – Diekrul

+0

@Diekrul ja es bleibt dort und erhöht sich nicht – user3518835

Antwort

1

Ich denke, die progressBar increse nicht, weil Sie Schritt de Fortschritt nicht. Wenn Sie setProgress auf 20 setzen, bleibt die Leiste bei 20.

Sie müssen progressive erhöhen, wenn Sie eine Bewegung sehen wollen.

Ich hoffe, es hilft.

0
private int progressStatus = 10;   
new Thread(new Runnable() { 
      public void run() { 

        while (progressStatus < 100) { 

          progressStatus += 5; 

          // Update the progress bar and display the 
          //current value in the text view 
          handler.post(new Runnable() { 
           public void run() { 
            progressBar.setProgress(progressStatus); 
         textView.setText(progressStatus+"/"+progressBar.getMax()); 

           } 
          }); 
          try { 
           // Sleep for 300 milliseconds. 
           //Just to display the progress slowly 
           Thread.sleep(300); 
          } catch (InterruptedException e) { 
           e.printStackTrace(); 
          } 


       } 

      } 
     }).start();