1. <legend id='uExtW'><style id='uExtW'><dir id='uExtW'><q id='uExtW'></q></dir></style></legend>

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

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

      如何在警报对话框中放置搜索栏?

      时间:2023-08-30
        <i id='wqNJW'><tr id='wqNJW'><dt id='wqNJW'><q id='wqNJW'><span id='wqNJW'><b id='wqNJW'><form id='wqNJW'><ins id='wqNJW'></ins><ul id='wqNJW'></ul><sub id='wqNJW'></sub></form><legend id='wqNJW'></legend><bdo id='wqNJW'><pre id='wqNJW'><center id='wqNJW'></center></pre></bdo></b><th id='wqNJW'></th></span></q></dt></tr></i><div id='wqNJW'><tfoot id='wqNJW'></tfoot><dl id='wqNJW'><fieldset id='wqNJW'></fieldset></dl></div>

        <legend id='wqNJW'><style id='wqNJW'><dir id='wqNJW'><q id='wqNJW'></q></dir></style></legend>

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

          <tfoot id='wqNJW'></tfoot>

            • <bdo id='wqNJW'></bdo><ul id='wqNJW'></ul>
                <tbody id='wqNJW'></tbody>

                本文介绍了如何在警报对话框中放置搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我希望在单击按钮后弹出一个警告对话框以显示搜索栏,以便人们可以将值从 1 更改为 48.我制作了一个自定义 xml,它有一个搜索栏和两个文本视图,我希望对话框有两个按钮,一个只是取消对话框,另一个做更多的工作.这是我到目前为止的代码.

                I want an alert dialog box to pop up after I click a button to have a seek bar so that the person can change the value from 1-48. I've made a custom xml that has a seek bar and two text view and I would like the dialog box to have two buttons, one just cancels the dialog and the other does more work. Here is the code I have so far.

                  <?xml version="1.0" encoding="utf-8"?>
                <RelativeLayout
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent">
                    <SeekBar android:max="48" android:layout_height="wrap_content" android:id="@+id/seekBar1" android:layout_width="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginTop="74dp"></SeekBar>
                    <TextView android:text="Change Hour Range" android:layout_height="wrap_content" android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"></TextView>
                    <TextView android:text="Only most recent positions" android:layout_height="wrap_content" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="15dp"></TextView>
                
                </RelativeLayout>
                

                这是我目前看到的警报对话框

                Here is the alert dialog that I have so far

                new AlertDialog.Builder(ImTracking.this)
                                    //is there something like setcontentview for alert dialogs?
                
                                    .setPositiveButton("Cancel", null)
                                    .setNegativeButton("OK",
                                            new DialogInterface.OnClickListener() {
                 // does some work here
                

                推荐答案

                是的 builder.setView(View v); 下面是如何使用它.

                Yep builder.setView(View v); here is how you can use it.

                    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot));
                    AlertDialog.Builder builder = new AlertDialog.Builder(this)
                    .setView(layout);
                    AlertDialog alertDialog = builder.create();
                    alertDialog.show();
                    SeekBar sb = (SeekBar)layout.findViewById(R.id.yourSeekBar);
                    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
                            //Do something here with new value
                        }
                    });
                

                在示例代码中添加了progressListener.请注意,在调用 alertDialog.show() 之前,您无法获得对 SeekBar 的引用,如果 SeekBar 未显示 findViewById() 将返回 null.另请注意,您必须使用 layout.findViewById(); 因为 SeekBar 是layout"引用的 RelativeLayout 的子级.

                Added progressListener to sample code. Do note that you cannot get a reference to your SeekBar until after you call alertDialog.show(), if the SeekBar is not being shown findViewById() will return null. Also note that you must use layout.findViewById(); because the SeekBar is a child of the RelativeLayout that 'layout' is a reference to.

                这篇关于如何在警报对话框中放置搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Facebook 请求对话框:本机 iOS 应用程序中的无摩擦 下一篇:无法创建圆角对话框(Android-Eclipse)

                相关文章

                最新文章

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

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

                    <legend id='l2x36'><style id='l2x36'><dir id='l2x36'><q id='l2x36'></q></dir></style></legend>
                  1. <small id='l2x36'></small><noframes id='l2x36'>