• <i id='M7mFR'><tr id='M7mFR'><dt id='M7mFR'><q id='M7mFR'><span id='M7mFR'><b id='M7mFR'><form id='M7mFR'><ins id='M7mFR'></ins><ul id='M7mFR'></ul><sub id='M7mFR'></sub></form><legend id='M7mFR'></legend><bdo id='M7mFR'><pre id='M7mFR'><center id='M7mFR'></center></pre></bdo></b><th id='M7mFR'></th></span></q></dt></tr></i><div id='M7mFR'><tfoot id='M7mFR'></tfoot><dl id='M7mFR'><fieldset id='M7mFR'></fieldset></dl></div>

  • <small id='M7mFR'></small><noframes id='M7mFR'>

  • <legend id='M7mFR'><style id='M7mFR'><dir id='M7mFR'><q id='M7mFR'></q></dir></style></legend>

      • <bdo id='M7mFR'></bdo><ul id='M7mFR'></ul>

      1. <tfoot id='M7mFR'></tfoot>

        Android,SeekBar 在对话框中

        时间:2023-08-30
        <tfoot id='jXaEr'></tfoot>

              <small id='jXaEr'></small><noframes id='jXaEr'>

              <i id='jXaEr'><tr id='jXaEr'><dt id='jXaEr'><q id='jXaEr'><span id='jXaEr'><b id='jXaEr'><form id='jXaEr'><ins id='jXaEr'></ins><ul id='jXaEr'></ul><sub id='jXaEr'></sub></form><legend id='jXaEr'></legend><bdo id='jXaEr'><pre id='jXaEr'><center id='jXaEr'></center></pre></bdo></b><th id='jXaEr'></th></span></q></dt></tr></i><div id='jXaEr'><tfoot id='jXaEr'></tfoot><dl id='jXaEr'><fieldset id='jXaEr'></fieldset></dl></div>
            • <legend id='jXaEr'><style id='jXaEr'><dir id='jXaEr'><q id='jXaEr'></q></dir></style></legend>
                <tbody id='jXaEr'></tbody>

                <bdo id='jXaEr'></bdo><ul id='jXaEr'></ul>
                1. 本文介绍了Android,SeekBar 在对话框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想在我的应用程序中使用带有搜索栏的对话框.但我真的不知道该怎么做,因为我缺乏使用 android 的经验.

                  I would like to use a dialog with a seekbar in my application. But I don't really know how to do it because I lack experience with android.

                  因此,当您按下按钮时:应该会出现一个带有搜索栏的对话框,用户可以输入一个值,然后按 OK 按钮.

                  So, when you press a button: a dialog should come up, with a seekbar and the user is able to enter a value and then press OK-button.

                  我现在的代码是developer.android的默认代码:

                  The code I have at the moment is the default code by developer.android:

                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                  builder.setMessage("Are you sure you want to exit?")
                          .setCancelable(false)
                         .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                             public void onClick(DialogInterface dialog, int id) {
                                  MyActivity.this.finish();
                         }
                     })
                     .setNegativeButton("No", new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int id) {
                              dialog.cancel();
                         }
                     });
                  AlertDialog alert = builder.create();
                  

                  如何添加SeekBar?

                  谢谢!

                  推荐答案

                  也许你可以考虑创建一个自定义对话框;它需要更多的工作,但它通常对我有用;)为您的对话框创建一个新的布局文件(例如 your_dialog.xml):

                  Maybe you could think of create a custom dialog; it requires more work but it usually works for me ;) Create a new layout file for your dialog (say, your_dialog.xml):

                  <RelativeLayout
                  android:id="@+id/your_dialog_root_element"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  >
                  
                  <SeekBar
                      android:id="@+id/your_dialog_seekbar"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      >
                  </SeekBar>
                  
                  <Button
                      android:id="@+id/your_dialog_button"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      >
                  </Button>
                  

                  然后,在你的活动中:

                  Dialog yourDialog = new Dialog(this);
                  LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
                  View layout = inflater.inflate(R.layout.your_dialog, (ViewGroup)findViewById(R.id.your_dialog_root_element));
                  yourDialog.setContentView(layout);
                  

                  因此,您可以对元素进行如下操作:

                  Thus, you can operate on your element as follows:

                  Button yourDialogButton = (Button)layout.findViewById(R.id.your_dialog_button);
                  SeekBar yourDialogSeekBar = (SeekBar)layout.findViewById(R.id.your_dialog_seekbar);
                  // ...
                  

                  等等,设置按钮和搜索栏的监听器.

                  and so on, to set listeners for button and seekbar.

                  seekbar onchangelistener 应该如下:

                  The seekbar onchangelistener should be as follows:

                  OnSeekBarChangeListener yourSeekBarListener = new OnSeekBarChangeListener() {
                      @Override
                      public void onStopTrackingTouch(SeekBar seekBar) {
                              //add code here
                      }
                  
                      @Override
                      public void onStartTrackingTouch(SeekBar seekBar) {
                              //add code here
                      }
                  
                      @Override
                      public void onProgressChanged(SeekBar seekBark, int progress, boolean fromUser) {
                              //add code here
                      }
                   };
                   yourDialogSeekBar.setOnSeekBarChangeListener(yourSeekBarListener);
                  

                  这篇关于Android,SeekBar 在对话框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:他们是如何做到的呢?主屏幕上的对话框 下一篇:Kotlin - Android 中的自定义对话框

                  相关文章

                  最新文章

                  <legend id='1lF7k'><style id='1lF7k'><dir id='1lF7k'><q id='1lF7k'></q></dir></style></legend>
                      <bdo id='1lF7k'></bdo><ul id='1lF7k'></ul>

                      <tfoot id='1lF7k'></tfoot>
                      <i id='1lF7k'><tr id='1lF7k'><dt id='1lF7k'><q id='1lF7k'><span id='1lF7k'><b id='1lF7k'><form id='1lF7k'><ins id='1lF7k'></ins><ul id='1lF7k'></ul><sub id='1lF7k'></sub></form><legend id='1lF7k'></legend><bdo id='1lF7k'><pre id='1lF7k'><center id='1lF7k'></center></pre></bdo></b><th id='1lF7k'></th></span></q></dt></tr></i><div id='1lF7k'><tfoot id='1lF7k'></tfoot><dl id='1lF7k'><fieldset id='1lF7k'></fieldset></dl></div>

                      <small id='1lF7k'></small><noframes id='1lF7k'>