安卓:在搜索栏设置间隔间隔

2023-09-12 09:47:20 作者:覆手倾天下

在我的应用我有一个显示在对话框中搜索栏。 现在,我想设置在搜索栏的间隔和步骤。间隔应该是0-250,每一个步骤应该是5分钟。

in my application i have a Seekbar that is shown in a dialog. Now i wanna set the interval and step in the seekbar. The interval should be 0-250 and each step should be 5 minutes.

到目前为止,这是我的code:

so far this is my code:

    public class seekActivity extends Activity implements OnClickListener,     OnSeekBarChangeListener  {
   SeekBar seekbar;
   Button button;
   TextView textview;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //set up main content view
        setContentView(R.layout.main);
        //this button will show the dialog
        Button button1main = (Button) findViewById(R.id.Button01main);


        button1main.setOnClickListener(this);

    }



        public void onClick(View v) {
                //set up dialog
                Dialog dialog = new Dialog(this);
                dialog.setContentView(R.layout.maindialog);
                dialog.setTitle("This is my custom dialog box");
                dialog.setCancelable(true);
                 button = (Button) dialog.findViewById(R.id.Button01);
                seekbar = (SeekBar) dialog.findViewById(R.id.seekBar1);
                seekbar.setOnSeekBarChangeListener(this);
                textview = (TextView) dialog.findViewById(R.id.textView1);
                dialog.show();

        }

        public class SeekBarPreference
        {

        }


        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {
            // TODO Auto-generated method stub
            textview.setText(progress + "");

        }
        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        };


            }

任何人都可以给我一些提示/ code怎么办?

Could anyone give me some tips/code how to do?

谢谢!

推荐答案

相反,这样做为什么不设置搜索栏的最大值为50(五分之二百五十),然后做任何转换就要从搜索栏值的真正的价值观?

Instead of doing this why not just set the max value of the SeekBar to 50 (250/5) and then do whatever conversion is necessary from the SeekBar values to "real" values?