android-edittext

Change the color of the cursor of an EditText in Android 3.0

与世无争的帅哥 提交于 2019-12-10 02:25:09
问题 I have to have an EditText in my application with a white background. I did this in my theme.xml file <style name="myEditText" parent="@android:style/Widget.EditText"> <item name="android:background">#ffffffff</item> <item name="android:textColor">#ff000000</item> </style> The problem now is that the cursor is still white and therefore not visible. I did some googling and found this question here on StackOverflow: Set EditText cursor color The way it's done there is the android

EditText input type textCapSentences not working on Lollipop

拈花ヽ惹草 提交于 2019-12-10 01:08:29
问题 I have implemeted android:inputType="textAutoComplete|textCapSentences" in my xml code. When I run it on kitkat , textCapSentence works fine but when build is run on Lollipop device it does not work. Anybody knows how to solve it. 回答1: Hi this is because in lollipop if you have disabled Auto - Capitalization in keyboard settings then you can't enable it programmatically. here are the steps:- Tap icon of ‘Settings’ on the Home screen of your Android Lollipop Device At the ‘Settings’ screen,

android: singleline = true not working for edittext

无人久伴 提交于 2019-12-10 00:45:49
问题 I want to restrict the edittext entry to a single line but When I add the line android:singleline = "true" , the hint is disappears, and after entering 26 characters the cursor is coming down. Here's my XML code: <EditText android:background="@drawable/edittxtborder" android:id="@+id/reglastname" android:singleLine="true" android:gravity="center" android:hint="@string/reglname" android:textSize="12dp" /> 回答1: add this code in your edittext xml code. android:ellipsize="end" this will work. 回答2

Save latest text from Edittext and restore it after onDestroy

橙三吉。 提交于 2019-12-09 22:22:00
问题 For my quote creator app, if the user wrote a text in the app and by accident closed the app and started it again, all the text will be gone. I want ofcourse to prevent that, and I have tried a common solution without succses: This is what I have done so far. I have removed unrelated code. public static EditText mEditText; private String savedText; private static final String SAVED_TEXT_KEY = ""; @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState);

Edit text with icons on both sides

混江龙づ霸主 提交于 2019-12-09 21:43:24
问题 I have to do an Edit Text with two Font Awesome Icons inside it: My problem is to add these icons (Left and Right), how can I do it? Here is my custom_search.xml drawable file: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFF"/> <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp"/>

Format EditText to currency with whole numbers

元气小坏坏 提交于 2019-12-09 19:10:32
问题 All- I have a TextWatcher that formats an EditText to currency format: private String current = ""; public void onTextChanged(CharSequence s, int start, int before, int count) { if(!s.toString().equals(current)){ editText$.removeTextChangedListener(this); String cleanString = s.toString().replaceAll("[$,.]", ""); double parsed = Double.parseDouble(cleanString); String formated = NumberFormat.getCurrencyInstance().format((parsed/100)); current = formated; editText$.setText(formated); editText$

Get numbers from EditText

假装没事ソ 提交于 2019-12-09 18:50:35
问题 I know that his have been asked a few times, but I have been trying everything I have found with no luck. I'm still having a error. Here's my code. xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:background="@android:color/transparent" android:gravity="center" android:orientation="vertical" > <TextView android:id="@

Android Custom EditText not showing cursor in ICS

假如想象 提交于 2019-12-09 16:39:54
问题 I have an EditText in my application which is to only receive inputs from buttons I have placed on the screen. To avoid the soft keyboard appearing I have a customised EditText class as follows: public class CustomEditText extends EditText { public CustomEditText(Context context) { super(context); } public CustomEditText(Context context, AttributeSet attrs) { super(context, attrs); } @Override // Disables Keyboard; public boolean onCheckIsTextEditor() { return false; } } This successfully

How to make EditText hint not to wrap?

徘徊边缘 提交于 2019-12-09 14:58:24
问题 I have a one line EditText, when I set a long hint, the hint wraps to two lines. Can I force the EditText to be always one line tall? android:lines="1" didn't work. 回答1: Have you tried android:ellipsize yet? This can be set to truncate the line to end in "..." either at the start, the middle, the end, or you can set it to marquee (scroll across). Not sure offhand whether this applies to hints or not, but it should. 回答2: Try android:singleLine="true" 回答3: Use android:maxLines="1" or android

How to correctly handle Android EditText input inside a ListView?

浪尽此生 提交于 2019-12-09 13:44:28
问题 In my application I have an activity to add/remove/edit records inside a SortedMap . The activity is implemented as an extension of ListActivity . I have implemented custom ArrayAdapter for the collection items. Every ListView item (which corresponds to an underlying record) consists of TextView s, EditText s, and a Button to delete the record itself. The layout is roughly as follows: ListView ---------------------------------------------------- [TextView] [EditText] [TextView] [EditText]