Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Enter in editText android

I have an EditText but I want only one line. I put lime this

<item name="android:maxLines">1</item> <item name="android:minLines">1</item> <item name="android:lines">1</item> 

but doesn't work.

enter image description here

See my code:

<LinearLayout style="@style/linearInputEntryText">     <LinearLayout  style="@style/subLinearLayout">         <TextView style="@style/label" android:text="Last Name" android:id="@+id/textView2"/>         <EditText style="@style/editTextEntryName" android:id="@+id/lastName"/>     </LinearLayout>     <View style="@style/linearInputEntryBlack" > </View> </LinearLayout> 

and styles:

<style name="editTextEntryName" parent="editTextEntry">     <item name="android:maxLines">1</item>     <item name="android:minLines">1</item>     <item name="android:lines">1</item>     <item name="android:layout_gravity">left</item> </style> 
like image 207
christian russo Avatar asked Aug 12 '15 12:08

christian russo


People also ask

How do I turn off edit text on android?

To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.

How do I get rid of Enter on my keyboard?

To remove a standard keyboard key, start by pressing down on the key in front of the key you want to remove. Insert a flat object below the key, such as a small flathead screwdriver or a car key, as shown in the picture. Once placed below the key, twist the flat object or push down until the key pops off.

What is the use of EditText in android?

A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.

What is the EditText attribute android inputType used for?

The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.


1 Answers

android:maxLines="1" allows the text to be multiline but limits the height of edittext to display a single line.

If you want to disable the enter (new line) key, set the input type to text

    android:inputType="text" 
like image 194
Shivam Avatar answered Sep 21 '22 12:09

Shivam