Edit text not editable android - android

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" />

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"

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">

Related

EditText does not display text instantly on some phone

In some phones, when I put EditText on the bottom of the screen, texts do not display instantly. Texts display only when soft-keyboard disappears(because of screen refresh). When I put editText on the top of soft-keyboard they are no problem.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="18sp"
android:maxLines="6"
android:minHeight="60dp"
android:paddingLeft="11dp"
android:paddingRight="5dp"
android:textColor="#color/blue_text_style"
android:id="#+id/titrePoste"
android:layout_toLeftOf="#id/btShare"
android:layout_alignParentBottom="true"
android:hint="#string/Objet"
android:background="#android:color/transparent"
android:backgroundTint="#color/color1"
android:textColorHint="#color/gray" />
java code
setContentView(R.layout.activity_post_pic_apercu);
titrePoste = (EditText) findViewById(R.id.titrePoste);
It's happens sometimes maybe you should add hardware Accelerated in manifest
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:roundIcon="#drawable/logo"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true">

Remove auto focus from EditText

I have 2 text fields in the start page. But the first text field gets auto focus after launch. I don't want this. I have seen couple of answers regarding this, but none of that work for me.
My Code
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:drawablePadding="12dp"
android:padding="10dp"
android:ems="10"
android:hint="Username"
android:inputType="textEmailAddress"
android:textColorHint="#android:color/white"
android:layout_marginTop="70dp"/>
I have added two more line here
android:focusable="true"
android:focusableInTouchMode="true"
But still it gets auto focus
Try this use android:windowSoftInputMode="stateAlwaysHidden" in manifest file of your Activity
<activity
android:name=".Youractivity"
android:windowSoftInputMode="stateAlwaysHidden" />
EDIT
I have added two more line here
android:focusable="true"
android:focusableInTouchMode="true"
the above line is used for requesting focus rather than not focusing

Android EditText was not completely visible when keyboard appears

My EditText was not completely visible when the keyboard appears, it was visible till focus but is there any possibility to view complete EditText.
Layout
<ScrollView
android:id="#+id/scrollvew_direct"
android:isScrollContainer="true"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_employers_name"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:inputType="text"
android:maxLength="100"
android:hint="#string/dir_deposit_6"
android:textSize="#dimen/edittextsize_sub"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/main_header"
android:textColorHint="#color/hint_color_light"
android:background="#drawable/edittext_style"/>
</ScrollView>
In mainfest
<activity
android:name=".activityname"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:theme="#android:style/Theme.Holo.Light.NoActionBar"/>
please guide me for proper solution.
In you activity tag of the manifest , add this property
android:windowSoftInputMode="adjustResize"
Edited :
Edittext height is not fully matched to the background drawable
make edittext as
android:layout_height="match_parent" or
android:layout_height="wrap_content"
and check it for me it is working
In you activity tag of the manifest , add this property
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"

Remove focus from EditText and also keep it editable

I am using EditText but when Activity is started my EditText is already focused. I want to remove focus and also make it editable on click.
Here is the code of my edittext.
<EditText
android:id="#+id/et_HotelLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:drawableLeft="#drawable/ic_edit_location_black_24dp"
android:drawablePadding="8dp"/>
You can create dummy layout as below which you should keep exactly above your EditText and then use nextFocusUp and nextFocusLeft as shown.
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:id="#+id/et"
android:drawablePadding="8dp"
android:nextFocusUp="#id/et"
android:nextFocusLeft="#id/et"
app:met_floatingLabel="normal" />
Add the following two properties in parent Layout of the Edit text
android:focusable="true"
android:focusableInTouchMode="true"
if your edit text is inside linear layout you can do like this
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_HotelLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:drawableLeft="#drawable/ic_edit_location_black_24dp"
android:drawablePadding="8dp"/>
</LinearLayout>
This question has already been responded here
Try this also -
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Otherwise, declare in your manifest file's activity -
<application android:icon="#drawable/icon"
android:label="#string/app_name">
<activity android:name=".Main"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden"
>

Automatically popup software keyboard when the app starts

I have an editText on the main page. I want the keyboard to open automatically when the app starts and to be focused on that editText. I tried many "solutions" I found on the Internet but nothing helped me.
The keyboard still doesn't appear automatically.
By the way, my editText has the following properties:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:gravity="left"
android:focusable="true"
android:enabled="true"
android:focusableInTouchMode="true" />
So how do I make the keyboard appear automatically?
You have to do two things (I have just tested this and it works just fine):
1: request focus for the field.
From the activity java file you can do
mTextView = (EditText) findViewById(R.id.textView);
mTextView.requestFocus();
From the XML file you can rewrite your element as follows:
<EditText android:id="#+id/textView">
<requestFocus/>
</EditText>
2: Force the keyboard when showing the activity: in the onCreate method just write this line:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Add android:windowSoftInputMode="stateAlwaysVisible" to your activity tag in the AndroidManifest.xml file
<activity
android:name=".TestActivity"
android:windowSoftInputMode="stateAlwaysVisible" />
Also use requestFocus tag in EditText.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:gravity="left"
android:focusable="true"
android:enabled="true"
android:focusableInTouchMode="true">
<requestFocus />
</EditText>
Call myeditText.requestFocus() after you initialize your layout on your activity's onCreate() method.

Categories

Resources