0

I have an Edit Text inside a custom ListView. When I am typing a value in the EditText, it is not showing what I type. If I tap several times on the EditText, it appears the typed text sometimes. How should I overcome this issue?

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/edtReason"
    android:background="@drawable/edittextstyle"
    android:layout_below="@+id/textView20"
    android:layout_toLeftOf="@+id/chkSelect"
    android:layout_alignLeft="@+id/textView20"
    android:layout_alignStart="@+id/textView20" />
Jas
  • 3,207
  • 2
  • 15
  • 45
creative Pro
  • 57
  • 1
  • 7
  • Please post custom ListView code. – Shoeb Siddique Mar 04 '16 at 06:54
  • 1
    Possible duplicate of [Focus on EditText in ListView when block descendants (Android)](http://stackoverflow.com/questions/20696631/focus-on-edittext-in-listview-when-block-descendants-android) – OneCricketeer Mar 04 '16 at 06:54
  • Basically, the ListView is taking the focus of the click instead of the EditText – OneCricketeer Mar 04 '16 at 06:55
  • Can you try adding android:descendantFocusability="blocksDescendants" to your edit text xml. I believe its a issue with list view. Even if you place a button on listview tapping it is pain :) I had the same issue "android:descendantFocusability" solved my problem :) – Sandeep Bhandari Mar 04 '16 at 06:56
  • @SandeepBhandari That goes on the ListView, not EditText – OneCricketeer Mar 04 '16 at 06:58
  • I added android:descendantFocusability="blocksDescendants" into my EditText. But nothing changed. Basically I have to type the characters and nothing is showed in the edit text. But once I tap in the EditText, I can see the text. – creative Pro Mar 04 '16 at 07:07
  • please have a look at my answer, if it does not work then post the xml file of the custom layout of your listview item – Awadesh Mar 04 '16 at 07:09

2 Answers2

0

Add these attributes and try again, Hope this helps

    android:hint="Enter Message"  
    android:inputType="textMultiLine|textPostalAddress"     
    android:focusable="true"
    android:clickable="true"       
    android:cursorVisible="true"
    android:layout_width="50dp"
    android:layout_height="wrap_content
    android:focusable="true"
    android:focusableInTouchMode="true"   
    android:textColor="#44444"
    android:ems="10"    

Add this in Manifest:

   android:windowSoftInputMode="adjustPan"

Manifest

  <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".ListviewActivity"
        android:screenOrientation="portrait" 
       android:windowSoftInputMode="adjustPan">
Arjun Singh
  • 724
  • 1
  • 8
  • 24
0

I hope you have added the following property in parent layout of your listview item

android:descendantFocusability="blocksDescendants"

Now add the following in xml of EditText

 android:focusableInTouchMode="true"
android:focusable="true"
Awadesh
  • 3,530
  • 2
  • 20
  • 32
  • ListView items are inside a RelativeLayout. What you are saying is add android:descendantFocusability="blocksDescendants" into the RelativeLayout ? I tried that, then keyboard is not popping up. – creative Pro Mar 04 '16 at 07:58
  • add android:windowSoftInputMode="adjustPan" in manifest file – Awadesh Mar 04 '16 at 08:01
  • This listview is loaded inside a fragment, not inside an Activity. So where do I add android:windowSoftInputMode="adjustPan" in manifest file? Under ? – creative Pro Mar 04 '16 at 08:10
  • Above worked for me if I add android:descendantFocusability="blocksDescendants" into the ListView. Sorry earlier I thought of adding listview item. Thanks for the help – creative Pro Mar 04 '16 at 08:20