0

我有一个 max=25 的搜索栏。我想要做的是当用户将搜索栏拖到最大值并且它处于按下状态时,而不是在达到最大值后搜索栏仍然连续递增,即 26、27、28、.... 100。(如果按下搜索栏)

我尝试了两种使用循环和线程的方法,但它们不起作用。

我有一个文本视图,我在上面显示进度的价值,

这是代码。

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   ");
                    }
                }


            }
4

1 回答 1

1

您需要使用 xml 属性android:max,例如

<SeekBar android:id="@+id/seekbartest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="25"/>

请参阅此处的文档

于 2013-01-31T08:03:34.830 回答