Android Seekbar增加值高达100
我有一个最大值为25的搜索栏。我想做的是,当用户将seekbar拖动到最大值时,它处于按下状态,而在达到最大值后,seekbar仍然持续递增,即26,27,28,。。。。100(如果按下搜索栏) 我尝试了两种使用循环和线程的方法,但都不起作用 我有一个文本视图,显示了进步的价值 这是代码Android Seekbar增加值高达100,android,android-intent,android-widget,seekbar,Android,Android Intent,Android Widget,Seekbar,我有一个最大值为25的搜索栏。我想做的是,当用户将seekbar拖动到最大值时,它处于按下状态,而在达到最大值后,seekbar仍然持续递增,即26,27,28,。。。。100(如果按下搜索栏) 我尝试了两种使用循环和线程的方法,但都不起作用 我有一个文本视图,显示了进步的价值 这是代码 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { flo
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
float p_prog = (float) (progress/10.0);
// TODO Auto-generated method stub
switch (seekBar.getId()) {
case R.id.seekbar_bar:
fat_count = p_prog;
if (p_prog == 0) {
txt_Fat.setBackgroundDrawable(res
.getDrawable(R.drawable.fat_at_null));
txt_Fat.setText(p_prog + "g ");
first_plus.setVisibility(View.GONE);
first_plus.setAnimation(null);
} else if (p_prog > 0 && p_prog < 3) {
txt_Fat.setBackgroundDrawable(res
.getDrawable(R.drawable.fat_green));
txt_bottom_description.setText("Fat started");
txt_Fat.setText(p_prog + "g ");
} else if (p_prog > 3 && p_prog < 20) {
txt_Fat.setBackgroundDrawable(res
.getDrawable(R.drawable.fat_yellow));
first_plus.setAnimation(null);
first_plus.setVisibility(View.GONE);
txt_Fat.setText(p_prog + "g ");
} else if (p_prog >= 20) {
txt_Fat.setBackgroundDrawable(res
.getDrawable(R.drawable.fat_red));
first_plus.setVisibility(1);
first_plus.startAnimation(anim);
txt_Fat.setText(p_prog+"g ");
if(s_Fat.isPressed() && p_prog >24){
for(float z=p_prog; z<100;z++){
txt_Fat.setText(z+"g ");
}
}
}
public void onProgressChanged(SeekBar-SeekBar,int-progress,
布尔值(用户){
浮动p_程序=(浮动)(进度/10.0);
//TODO自动生成的方法存根
开关(seekBar.getId()){
案例R.id.seekbar\u栏:
fat_计数=p_程序;
如果(p_prog==0){
txt_Fat.可缩回地面牵引(res
.getDrawable(R.drawable.fat_at_null));
txt_Fat.setText(p_prog+“g”);
first_plus.setVisibility(View.GONE);
first_plus.setAnimation(null);
}否则如果(p_程序>0和p_程序<3){
txt_Fat.可缩回地面牵引(res
.getDrawable(R.drawable.fat_green));
txt_bottom_description.setText(“Fat启动”);
txt_Fat.setText(p_prog+“g”);
}否则如果(p_程序>3和p_程序<20){
txt_Fat.可缩回地面牵引(res
.getDrawable(R.drawable.fat_yellow));
first_plus.setAnimation(null);
first_plus.setVisibility(View.GONE);
txt_Fat.setText(p_prog+“g”);
}否则,如果(p_prog>=20){
txt_Fat.可缩回地面牵引(res
.getDrawable(R.drawable.fat_red));
第一加设置可见性(1);
第一个动画(动画);
txt_Fat.setText(p_prog+“g”);
如果(s_Fat.isPressed()&&p_prog>24){
对于(float z=p_prog;z您需要使用xml属性android:max
like
<SeekBar android:id="@+id/seekbartest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="25"/>
请参阅文档我已经设置了此值。我想在达到最大值25后增加该值。并且seekbar与我一样处于按下状态。如果(s_Fat.isPressed()&&p_prog>24)是,我不会得到超过25。当它达到最大值(25)时我想增加/增加它到100,当它处于按下状态时也是如此。那么为什么你将最大值定义为25?以及你如何确定按下状态?我定义它是因为当用户移动seekbar并达到20时,与进度大于20时相比,textview的背景将变为红色。当它达到25时,这是结束时,它应该在文本视图中不断增加值。这会向用户显示seekbar已达到最大值,但该值会不断增加确定按下状态的方式??是否捕获seekbar的onClick??如果是,可以将检查移动到onClick本身内部。