Android Studio(1.5)在使用自定义组件时挂起

Android Studio(1.5)在使用自定义组件时挂起,android,android-studio,Android,Android Studio,我正在尝试在我的应用程序中使用自定义组件。代码如下: 布局文件(选择方法布局): 在主课堂上,我是这样使用它的: final AlertDialog.Builder dialog=new AlertDialog.Builder(this); dialog.setTitle(getString(R.string.firsttime)); LayoutInflater inflater = getLayoutInflater(); Vi

我正在尝试在我的应用程序中使用自定义组件。代码如下:

布局文件(选择方法布局):

在主课堂上,我是这样使用它的:

        final AlertDialog.Builder dialog=new AlertDialog.Builder(this);
        dialog.setTitle(getString(R.string.firsttime));
        LayoutInflater inflater = getLayoutInflater();
        View dialoglayout = inflater.inflate(R.layout.select_method_layout, null);
        dialog.setView(dialoglayout);
        ComponenteSelectMethod cFile=(ComponenteSelectMethod)dialoglayout.findViewById(R.id.methodfile);
        ComponenteSelectMethod cService=(ComponenteSelectMethod)dialoglayout.findViewById(R.id.methodservice);
        LinearLayout layoutFile=(LinearLayout)dialoglayout.findViewById(R.id.layoutmethodfile);
        LinearLayout layoutService=(LinearLayout)dialoglayout.findViewById(R.id.layoutmethodservice);
        cFile.setImage(R.drawable.icono_archivo_agu);
        cFile.setText(getString(R.string.textexplicacionfile));
        cService.setImage(R.drawable.icono_directorio);
        cService.setText(getString(R.string.textexplicacionservice));
        final AlertDialog methodDialog=dialog.show();
        layoutFile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settings.edit().putString("method", "file").apply();
                methodDialog.dismiss();
                proceder();
            }
        });
        layoutService.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settings.edit().putString("method", "service").apply();
                methodDialog.dismiss();
                proceder();
            }
        });
编辑:

组件\选择\方法\布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="@string/encabezadometodo"
    android:id="@+id/encabezadometodo"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textStyle="bold"/>

<es.infaplic.aguaics.Componentes.ComponenteSelectMethod
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/methodfile"
    android:layout_below="@+id/textexplicacion"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<es.infaplic.aguaics.Componentes.ComponenteSelectMethod
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/methodservice"
    android:layout_below="@+id/methodfile"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/layoutmethodservice"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/servicemethod"
        android:id="@+id/service"
        android:gravity="center"
        />
</LinearLayout>

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/layoutmethodfile"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_above="@id/layoutmethodservice">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/filemethod"
        android:id="@+id/file"
        android:gravity="center"
        />

</LinearLayout>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="@string/textexplicacion"
    android:id="@+id/textexplicacion"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/encabezadometodo"
    android:gravity="center"/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout     
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<ImageView
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:id="@+id/imageiconoselectmethod"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text=""
    android:id="@+id/textmethod"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/imageiconoselectmethod"
    android:layout_toEndOf="@+id/imageiconoselectmethod"
    android:layout_marginStart="30dp"
    android:layout_marginLeft="30dp"/>
</RelativeLayout>

这样,当我打开xml文件时,它无法呈现。它停留在“渲染…”中,不再执行任何操作。如果我在布局编辑中访问文本模式,并执行任何操作(如点击空格键),Android Studio将停止响应

我的自定义组件有问题吗?有人知道如何避免Android Studio挂起吗


谢谢。

您是否在布局xml预览器中手动选择了主题?如果我不这样做的话,虫子往往会发生在我身上(比如尝试全息灯),但我真的不明白为什么…我什么都没碰。生成了文件,拖拽了组件…事情发生了。我甚至无法退出Android Studio。必须强制关闭它…尝试了你的建议,但什么也没发生。谢谢。请分享版面:
select\u method\u layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout     
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<ImageView
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:id="@+id/imageiconoselectmethod"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text=""
    android:id="@+id/textmethod"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/imageiconoselectmethod"
    android:layout_toEndOf="@+id/imageiconoselectmethod"
    android:layout_marginStart="30dp"
    android:layout_marginLeft="30dp"/>
</RelativeLayout>