user2320431
user2320431

Reputation: 115

EditText is not clickable inside a fragment

I have a "has_groups_fragment" fragment, and it has an EditText element. When I try to click on it, the keyboard is not responding.

the layout is the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/has_groups"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ft_background"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/searchGroupsArea"
        android:layout_width="350dp"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/inputGroupSearch"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_weight="0.86"
            android:clickable="true"
            android:ems="10"
            android:hint="Search a group..."
            android:inputType="textVisiblePassword"
            android:textIsSelectable="true" >

            <requestFocus />
        </EditText>

        <ImageView
            android:id="@+id/magnifyingGlass"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:src="@drawable/search_icon" />
    </LinearLayout>

    <ListView
        android:id="@+id/groupsList"
        android:layout_width="fill_parent"
        android:layout_height="407dp"
        android:layout_weight="1.52"
        android:choiceMode="singleChoice" />

</LinearLayout>

Any advices? Thanks a lot!

Upvotes: 1

Views: 1019

Answers (3)

Christopher Francisco
Christopher Francisco

Reputation: 16288

Try removing both android:clickable and android:textIsSelectable attributes

Upvotes: 0

C0D3LIC1OU5
C0D3LIC1OU5

Reputation: 8680

I think you might have forgotten to add this to your activity, in your AndroidManifest.xml file:

<activity android:name="your_activity_name"
              ...
              android:windowSoftInputMode="adjustPan"
              ...>

More information

Upvotes: 0

Mike M.
Mike M.

Reputation: 39201

I believe the following attribute is the problem:

 android:textIsSelectable="true"

When this is set to true for an EditText View, it allows text in the EditText to be selected, but it disallows editing of the text, which is why the keyboard doesn't show.

If you just want to allow normal copy/paste procedures, you don't need to set this.

Upvotes: 1

Related Questions