所以我想从搜索栏取得进展并在按钮方法中使用它,但它总是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(counter));将一直显示0。我不知道如何解决它
答案 0 :(得分:1)
尝试改变它:
@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)));
}