Android EditText无法输入文字

标签 android android-layout android-fragments android-edittext

下面是聊天页脚,它包含在聊天 fragment 中。理想情况下,用户应该能够键入他的消息并发送它。但是,我们甚至无法在编辑文本框内单击。

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffffff">

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/backIcon"
        android:src="@drawable/back_button"
        android:background="@null"
        android:layout_row="0"
        android:layout_column="0"
        android:layout_gravity="center|left"
        android:layout_marginLeft="16dp" />

        <EditText
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:id="@+id/chat_type"
            android:inputType="textMultiLine"
            android:textSize="10dp"
            android:background="@drawable/rounded_corners"
            android:padding="16dp"
            android:textColor="#ff8888"
            android:layout_gravity="top"
            android:enabled="true"
            android:clickable="true"
            android:imeOptions="actionNext"/>

        <ImageButton
            android:id="@+id/chat_send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/footer_chat_send_normal"
            android:background="@null"
            android:layout_marginLeft="-68dp"
            android:padding="16dp"/>
    </GridLayout>
</RelativeLayout>

下面是fragment_chat.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#fff">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#9700d4">
    <FrameLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center">

        <com.glynk.app.custom.widgets.CircularImageView
            android:id="@+id/fragment_feed_user_picture"
            android:layout_width="65dp"
            android:layout_height="65dp"
            android:padding="50dp"
            android:src="@drawable/animal_cat"
            android:layout_marginTop="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="30dp" />



    </FrameLayout>
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="340dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.8">

        <TextView
            android:id="@+id/fragment_feed_user_name"
            style="@style/WhiteNormal14"
            android:layout_marginTop="25dp"
            android:text="Test"/>

        <TextView
            android:id="@+id/details"
            style="@style/WhiteNormal12"
            android:text="M 38 Sunnyvale"/>
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:id="@+id/percentage"
                style="@style/WhiteNormal12"
                android:text="100"/>
            <TextView
                style="@style/WhiteNormal12"
                android:text="%"
                android:layout_marginLeft="20dp"/>
            <TextView
                android:id="@+id/match_topic"
                style="@style/WhiteNormal12"
                android:layout_marginLeft="30dp"
                android:text="in Relationship" />
        </RelativeLayout>

    </LinearLayout>
</LinearLayout>


<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="400dp">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/roundcorner_white"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll"
        android:id="@+id/messageTextView" />
</LinearLayout>
<include
    android:id="@+id/messagesFooter"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_marginTop="10dp"
    android:layout_below="@+id/listView"
    layout="@layout/chat_footer"/>

</LinearLayout>

无法在内部编辑/输入或单击。 可能是什么原因?

最佳答案

你可以用

EditText.setEnabled(false);

关于Android EditText无法输入文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30852276/

相关文章:

Java : Subclassing AsyncTask

Android关闭滚动动画

android - 在使用 android studio 运行 Espresso 测试时。我收到以下错误

android - 在 TextView 中对齐第一行

android - 如何重用已在 Navigation Drawer 上实例化的 fragment ?

java - 更新recyclerView

android - 从 dialogfragment 设置 fragment edittext 值

java - 当我单击“计算”按钮以显示我的结果时应用程序崩溃

java - 问号对我来说很陌生

android - 波纹可绘制在 xml 中不起作用