Handling click events on a drawable within an EditText

I have added an image right of the text in an EditText widget, using the following XML: <EditText android:id=”@+id/txtsearch” … android:layout_gravity=”center_vertical” android:background=”@layout/shape” android:hint=”Enter place,city,state” android:drawableRight=”@drawable/cross” /> But I want to clear the EditText when the embedded image is clicked. How can I do this? 41 Answers 41 Actually you don’t need to extend any class. … Read more

Password hint font in Android

When an EditText is in password mode, it seems that the hint is shown in a different font (courrier?). How can I avoid this? I would like the hint to appear in the same font that when the EditText is not in password mode. My current xml: <EditText android:hint=”@string/edt_password_hint” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:password=”true” android:singleLine=”true” /> 18 … Read more

Changing EditText bottom line color with appcompat v7

I am using appcompat v7 to get the look consistent on Android 5 and less. It works rather well. However I cannot figure out how to change the bottom line color and the accent color for EditTexts. Is it possible? I have tried to define a custom android:editTextStyle (cf. below) but I only succeeded to … Read more

restrict edittext to single line

possible duplicate : android-singleline-true-not-working-for-edittext <EditText android:id=”@+id/searchbox” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:lines=”1″ 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> I want to make the above EditText to have only single line. Even if the user presses “enter” the cursor should not get down to the second line. Can anybody help me doing that? 24 … Read more