所以我想从搜索栏取得进展,并在按钮方法中使用它,但它始终是0(counter),没有作用。我尝试了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(counter));将一直显示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)));
}