Tag: android-edittext

What's the right way to extend EditText to give it additional “default” functionality

I’m wondering if it’s possible to add functionality to EditText such that when I include my newly extended field in the layout xml, I don’t have to then add any code to the Activity class to get it to behave in specific ways. For example, I’d like to make a EditPhone field which is just […]

requestFocus doesn't work properly for EditText

A lot of time was spent to solve the problem, and it looks easy, but I’m really tired and couldn’t find the solution. I have an Activity, activity has 4 EditText components, 2 of them has popup menu (AlertDialog) which contain the list, next one – is disabled for edit, and last one – is […]

Handle enter key in EditText across different devices

Right now I’m handling the enter key in my EditText fields using a an onEditorActionListener and looking at the Action ID for IME_NULL. It works fine for all my users except one. She has an Xperia Arc. TextView.OnEditorActionListener keyListener = new TextView.OnEditorActionListener(){ public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if(actionId == EditorInfo.IME_NULL){ if(((EditText)findViewById(view.getId())) […]

Android: How to make an AutoCompleteTextView SingleLine?

<AutoCompleteTextView android:id=”@+id/product” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:hint=”product” android:singleLine=”true” android:textColor=”@color/white” android:textSize=”15dp” /> this is my code for AutoCompleteTextView. The problem is I want to type in some text and then click Next on the soft-keyboard. Next is not appearing on the soft-keyboard but its not taking cursor to the next EditText. In the same screen rest all EditText […]

Better way to get all the text in an EditText from an InputConnection?

I’ve written an IME (InputMethodService) and I need to get all the text from the EditText it is editing. I know one way: InputConnection inputConnection = getCurrentInputConnection(); inputConnection.append(inputConnection.getTextBeforeCursor(9999, 0)) .append(inputConnection.getTextAfterCursor(9999, 0)); It works, but it seems pretty stupid and clunky. However there is no such method InputConnection.getText(). Is there a better way? P.S. I cannot […]

Android EditText on longPress: ArrayIndexOutOfBoundsException: length=15; index=491

I have this strange behavior I cannot explain. My layout is quite simple: An EditText: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:gravity=”center” android:orientation=”vertical” android:padding=”10dp” > <EditText android:id=”@+id/etPass” android:layout_width=”match_parent” android:layout_height=”wrap_content” /> </LinearLayout> When I try to longPress it (to paste some text) I got an imediate Force Close and this error: 05-08 16:56:16.838: E/AndroidRuntime(12164): FATAL […]

Problem with Android's EditText : KeyListener

On an EditText component, I’m trying to set a KeyListener in order to catch the ENTER key (for form validation). text.setKeyListener(new KeyListener() { @Override public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) { return false; } @Override public boolean onKeyOther(View view, Editable text, KeyEvent event) { return false; } @Override public boolean onKeyDown(View […]

vibration of Edittext in android

i want to create a edit text that will vibrate if given input is invalid. for example edit text for number if number is wrong like it contain 9 digits than edit text will became clear and will vibrate for some time how to create that? thanks in advance

Custom EditText is not showing keyboard on focus

I am creating a custom EditText class because i need to set some custom fonts; However now when i click on the editText the android keyboard does not pop up anymore… here is my class: package ro.gebs.captoom.utils.fonts; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.Typeface; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import ro.gebs.captoom.R; public class […]

how can I set the margin of a EditText using xml?

hi all i have created layout using following code android:layout_height=”wrap_content”></TextView> <EditText android:layout_height=”wrap_content” android:padding=”12dip” android:layout_width=”wrap_content” android:text=”EditText” android:id=”@+id/editText1″></EditText> </TableRow> </TableLayout> <TableRow android:layout_width=”match_parent” android:id=”@+id/tableRow2″ android:layout_height=”wrap_content”> <TextView android:text=”TextView” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:id=”@+id/textView2″></TextView> <EditText android:text=”EditText” android:id=”@+id/editText2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”></EditText> </TableRow> <TableRow android:layout_width=”match_parent” android:id=”@+id/tableRow3″ android:layout_height=”wrap_content”> <Button android:text=”Button” android:id=”@+id/button1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”></Button> <Button android:text=”Button” android:id=”@+id/button2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content”></Button> </TableRow> but now i want to set the […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.