2017-04-14 53 views
0

所以我想從尋求酒吧取得進展,並在按鈕方法中使用它,但它總是0(計數器),不工作。我試圖seekB.getProgress();搜索條的偉大工程......我如何從seekbar獲取進度?

int counter; 

seekB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 

     @Override 
     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
      counter = progress; 
      seekbarValue.setText(String.valueOf(progress)); 

     } 

     @Override 
     public void onStartTrackingTouch(SeekBar seekBar) { 


     } 

     @Override 
     public void onStopTrackingTouch(SeekBar seekBar) { 

     } 
    }); 

    //Randomise Button 

    but.setOnClickListener(new View.OnClickListener() { 

     int Plength = 6; 

     char[] i = new char[Plength]; 

     List<Character> pass = new ArrayList<>(); 


     @Override 
     public void onClick(View v) { 


      for (int x = 0; x < Plength; x++) { 
       pass.add(azL[rand.nextInt(azL.length)]); 
       pass.add(nzL[rand.nextInt(nzL.length)]); 
       pass.add(AZL[rand.nextInt(AZL.length)]); 

       i[x] = pass.get(rand.nextInt(pass.size())); 


      } 
      textV.setText(String.valueOf(i)); 
      pass.clear(); 
     } 

    }); 

,如果我做textV.setText(將String.valueOf(計數器));會顯示0所有再寄一次不知道如何解決它

+0

顯示烏爾計數器變量聲明 – sravs

+0

@sravs我做到了...現在? – Dubli

+0

你的櫃檯應該工作..之間你是否使用計數器變量?你不直接使用seekB.getProgress()? – sravs

回答

0

試圖改變它:

@Override 
     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
      counter = progress; 
      seekbarValue.setText(String.valueOf(progress)); 
} 

@Override 
      public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
counter = progress; 
seekbarValue.setText(String.valueOf(new Integer(progress))); 
}