android-edittext

EditText items in a scrolling list lose their changes when scrolled off the screen

拈花ヽ惹草 提交于 2019-11-30 06:02:46
问题 I have a long scrolling list of EditText items created by a SimpleCursorAdapter and prepopulated with values from an SQLite database. I make this by: cursor = db.rawQuery("SELECT _id, criterion, localweight, globalweight FROM " + dbTableName + " ORDER BY criterion", null); startManagingCursor(cursor); mAdapter = new SimpleCursorAdapter(this, R.layout.weight_edit_items, cursor, new String[]{"criterion","localweight","globalweight"}, new int[]{R.id.criterion_edit, R.id.localweight_edit, R.id

How to change the color of a focused EditText when using “android:Theme.Holo.Light”?

孤人 提交于 2019-11-30 05:40:46
问题 I Am using "android:Theme.Holo.Light" in my application, it gives blue as the Default color. I want to have a EditText when focused like below. By default it comes like this when applying holo.light theme . 回答1: You can use Holo Color generator for custom colors. http://android-holo-colors.com/ You don't need to download all controls. Only these you want. 回答2: May this help you: You will have to create/modify your own NinePatch image to replace the default one, and use that as the background

Get text string from EditText?

老子叫甜甜 提交于 2019-11-30 05:36:16
It seems I can't figure out how to get the text string out of EditText . I want to use the text from the EditText at pressing the button. layout.xml : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/popup_menu_root" android:background="#FFFFFF" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/popup_menu_button" android:text="ok" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <EditText android:id="@+id

How to Prevent Keyboard appearing for EditText that is not enabled

假如想象 提交于 2019-11-30 05:17:18
问题 My activity has an EditText which is supposedly not editable until user clicks on edit button for the screen. I did edit.setEnabled(false) but still a keyboard appears for the user and values can be added to the EditText in the screen via the keyboard even though the screen might look a bit greyed out. What else do I have to do to prevent editing of the EditText until user has specifically pushed an edit button. Thanks, Steve 回答1: Attention that setEditable is depecrated. You can use :

Problem with android password field, not hiding the last character typed

筅森魡賤 提交于 2019-11-30 05:14:10
问题 In Android, I create a password field like this: EditText text = new EditText(context); text.setTransformationMethod(PasswordTransformationMethod.getInstance()); Or like this, which seems to do the same thing: EditText text = new EditText(context); text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); I get a nice password field except for the last character typed by the user. It's visible on the screen for a few seconds before beeing masked with a dot. Here

How to detect if users stop typing in EditText android

孤者浪人 提交于 2019-11-30 04:58:38
I have an EditText field in my layout. I want to perform an action when the user stops typing in that edittext field. I have implemented TextWatcher and use its functions @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { } @Override public void afterTextChanged(Editable editable) { } The function onTextChanged and afterTextChanged get called just after typing any character, but I want to perform action after the user has finished typing in that

Why does Android change the value of EditTexts with same id?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 04:57:00
I have a Fragment containing a LinearLayout where different items are inflated depending on some business logic. On of these items contains an EditText. When I have multiple of these items with different content and I detach/attach the fragment, all EditTexts somehow get all the same text. This only happens as long as the the EditText has an id in the layout file. Why does that happen? Is there any other way to prevent this except removing the id? I would like to use findViewById on my inflated items to access the views instead of error prone getChildAt . I've created a minimalistic example to

Android XML - moving between EditText fields

♀尐吖头ヾ 提交于 2019-11-30 04:55:13
问题 I've got 2 Fragments that have a couple of EditText boxes on. They are both laid out similar, however its very strange that 1 will tab between the EditText fields, but the other won't. This is the one i'm having problems with: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/loginparent" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff008DFF" >

Converting String to Double in Android

坚强是说给别人听的谎言 提交于 2019-11-30 04:55:08
Trying to get double values from an EditText and manipulate them before passing them to another Intent. Not using primitive data type so I can use toString methods. Problem is when I include the protein=Double.valueOf(p).doubleValue(); style commands, the program force closes immediately without leaving any info in the logcat.If I comment them out and set some dummy data like protein = 1.0; it works with no problems. Same happens with primitive data types and parse double. This code works perfectly with dummy data in normal java. What am I doing wrong? EditText txtProt, txtCarb, txtFat,

Android EditText : How to apply Foreground color span as you type?

南笙酒味 提交于 2019-11-30 04:51:22
问题 I'm trying to apply a font color to text in an EditText as you type text. However, its just very inconsistent, meaning that sometimes if you type a space, the text preceding that space will go back to the default black color. Or if I put my cursor in the middle of a word and start typing the entire word changes color and not just the text I'm typing. The bold, italic and underline seem to work well though. How can I guarantee that only the text I'm typing will be affected with regards to font