Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在自定义对话框中使用微调器?_Java_Android_Android Layout - Fatal编程技术网

Java 如何在自定义对话框中使用微调器?

Java 如何在自定义对话框中使用微调器?,java,android,android-layout,Java,Android,Android Layout,我想在自定义对话框中使用微调器。我使用活动显示为对话框,在活动内部使用微调器。但当将活动转换为对话框微调器的项目时,不会显示 我的XML代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="ht

我想在自定义
对话框中使用
微调器
。我使用
活动
显示为
对话框
,在活动内部使用
微调器
。但当将活动转换为对话框微调器的项目时,不会显示

我的XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/add_sms_dialog_background"
    tools:context="com.tellfa.smsbox.addSMS_Page">

    <RelativeLayout
        android:id="@+id/addSMS_cover_layout"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:background="@drawable/add_sms_dialog_coverlayout">

        <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/addSMS_profile_image"
            android:layout_width="85dp"
            android:layout_height="85dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_margin="5dp"
            android:src="@drawable/all_users_avatar"
            app:border_color="@color/activity_bg_color"
            app:border_width="2dp" />

        <com.tellfa.smsbox.components.tellfa_TextView
            android:id="@+id/addSMS_title_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_toLeftOf="@+id/addSMS_profile_image"
            android:text="title"
            android:textColor="@color/activity_bg_color"
            android:textSize="23sp" />

        <ImageView
            android:id="@+id/addSMS_close_image"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_centerVertical="true"
            android:layout_margin="5dp"
            android:alpha="0.7"
            android:src="@drawable/close_dialog" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/addSMS_smsInfo_layout"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:layout_below="@+id/addSMS_cover_layout"
        android:layout_marginBottom="200dp">

        <com.rey.material.widget.Spinner
            style="@style/Material.Widget.Spinner.Light"
            android:id="@+id/spinner_no_arrow"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:minWidth="128dp"
            android:layout_marginTop="16dp"
            app:rd_style="@style/Material.Drawable.Ripple.Wave.Light"
            app:rd_enable="true"
            app:spn_labelEnable="true"
            app:spn_label="Spinner without arrow"
            app:spn_arrowSize="0dp"
            app:spn_popupItemAnimation="@anim/abc_fade_in"/>

    </RelativeLayout>

</RelativeLayout>
final Dialog dialog = new Dialog(Main_Page.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.add_sms);
                dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
                Window window = dialog.getWindow();
                window.setLayout(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                dialog.setCancelable(false);

                ImageView closeDialog_image = (ImageView) dialog.findViewById(R.id.addSMS_close_image);
                closeDialog_image.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                    }
                });

                dialog.show();
            }
        });
我将此库用于微调器


如何修复它?

为微调器提供适配器,如果没有适配器,将不会显示任何项目。请在对话框中提供此代码

String[] items ={"item 1","item 2","item 3"};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_item,items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

Spinner spin=(Spinner)dialog.findViewById(R.id.spinner_no_arrow);
spin.setAdapter(adapter);
String[]items={“item 1”、“item 2”、“item 3”};
ArrayAdapter=新的ArrayAdapter(getApplicationContext(),android.R.layout.simple\u微调器\u项,项);
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
微调器旋转=(微调器)dialog.findViewById(R.id.Spinner\u no\u箭头);
spin.setAdapter(适配器);

您是否提供了一个适配器,其中包含spinner@L-十、 tnx但是如何修复它呢?tnx,我正在将此代码插入对话框代码,但是现在启动ApplicationControl时显示FC错误,更新了代码,如果仍然出现错误,请告诉我