Disable soft-keyboard from EditText but still allow copy/paste?

After hours and hours of research, I finally found a solution that works for all API versions. Hope this saves someone’s time. If you are developing for API >= 11, the solution is simple, either: 1) Add the two properties below in the xml file of EditText android:inputType=”none” android:textIsSelectable=”true” or 2) Programatically do the below … Read more

restrict edittext to single line

Use android:maxLines=”1″ and android:inputType=”text” You forgot the android:maxLines attribute. And refer for android:inputType With your example, below will give this result: <EditText android:id=”@+id/searchbox” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:maxLines=”1″ android:inputType=”text” android:scrollHorizontally=”true” android:ellipsize=”end” android:layout_weight=”1″ android:layout_marginTop=”2dp” android:drawablePadding=”10dp” android:background=”@drawable/edittext” android:drawableLeft=”@drawable/folder_full” android:drawableRight=”@drawable/search” android:paddingLeft=”15dp” android:hint=”search…”> </EditText>

First letter capitalization for EditText

Statically (i.e. in your layout XML file): set android:inputType=”textCapSentences” on your EditText. Programmatically: you have to include InputType.TYPE_CLASS_TEXT in the InputType of the EditText, e.g. EditText editor = new EditText(this); editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); Can be combined with text and its variations to request capitalization of the first character of every sentence. – Google Docs

Allow multi-line in EditText view in Android?

By default all the EditText widgets in Android are multi-lined. Here is some sample code: <EditText android:inputType=”textMultiLine” <!– Multiline input –> android:lines=”8″ <!– Total Lines prior display –> android:minLines=”6″ <!– Minimum lines –> android:gravity=”top|start” <!– Cursor Position –> android:maxLines=”10″ <!– Maximum Lines –> android:layout_height=”wrap_content” <!– Height determined by content –> android:layout_width=”match_parent” <!– Fill entire width … Read more

How to change style of a default EditText

Create xml file like edit_text_design.xml and save it to your drawable folder i have given the Color codes According to my Choice, Please Change Color Codes As per your Choice ! <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape> <solid android:color=”#c2c2c2″ /> </shape> </item> <!– main color –> <item android:bottom=”1.5dp” android:left=”1.5dp” android:right=”1.5dp”> <shape> <solid android:color=”#000″ … Read more

How to get data from each dynamically created EditText in Android?

In every iteration you are rewriting the ed variable, so when loop is finished ed only points to the last EditText instance you created. You should store all references to all EditTexts: EditText ed; List<EditText> allEds = new ArrayList<EditText>(); for (int i = 0; i < count; i++) { ed = new EditText(Activity2.this); allEds.add(ed); ed.setBackgroundResource(R.color.blackOpacity); … Read more