android-edittext

EditText not automatically saved on screen orientation change

女生的网名这么多〃 提交于 2019-12-17 11:45:21
问题 I read that Android automatically saves the content of EditText objects when an application is about to be stopped or killed. However, in my app the content of an EditText is lost when screen orientation changes. Is it normal behaviour? Do I then have to manually save/restore its content with onSaveInstanceState / onRestoreInstanceState ? Or is there an easier method to tell Android to save it end restore it? Edit : I create the EditText object programmatically, not in XML. This turns out to

null keyevent and actionid = 0 in onEditorAction() (Jelly Bean / Nexus 7)

一世执手 提交于 2019-12-17 11:27:30
问题 I have an edit text which functions as a search box in my application. In Jelly Bean on my Nexus 7 when I type something into the text box which I am listening on and hit enter the KeyEvent = null and ActionId = 0 passed into the onEditorAction() method. Has anyone else encountered this? I'm thinking it might be a bug. In the second if statement below I get a null pointer because the actionId = 0 and KeyEvent = null; // Search field logic. @Override public boolean onEditorAction(TextView v,

Iterate through ListView and get EditText-Field values

和自甴很熟 提交于 2019-12-17 10:59:08
问题 I've created a ListView (myList) with one EditText-Field in each row (R.id.mannschaften). Under the ListView, I've created a Button and set an OnClickListener for it in the OnCreate()-Method. Now when the Button is clicked, I want to iterate through the ListView and get the value of the EditText-Field in every row and save them in a String-List. But how do I do that? Here is my Code: private void ButtonClick() { /** get all values of the EditText-Fields */ View v; ArrayList<String>

How to Get EditText maxLength setting in code

对着背影说爱祢 提交于 2019-12-17 10:58:14
问题 I would like to see the maxLength of an EditText at run time to be able to make a text display decision. Is that possible? Here is a description of what I wan't to do. I have a ListView with many rows and each row have an EditText and a TextView. I've made a subclass of ArrayAdapter to be able to feed the String that I want to place in the EditText of each row. I have set android:maxLength="12" in the XML file. I want to display a number in that EditText field, but if the number I want to

How to Get EditText maxLength setting in code

自作多情 提交于 2019-12-17 10:58:09
问题 I would like to see the maxLength of an EditText at run time to be able to make a text display decision. Is that possible? Here is a description of what I wan't to do. I have a ListView with many rows and each row have an EditText and a TextView. I've made a subclass of ArrayAdapter to be able to feed the String that I want to place in the EditText of each row. I have set android:maxLength="12" in the XML file. I want to display a number in that EditText field, but if the number I want to

Show Error on the tip of the Edit Text Android

流过昼夜 提交于 2019-12-17 10:53:35
问题 I want to show error if the user enters blank value in the edittext.But i am not getting the way how could i do this .This is how i want like this: This is my xml that i have created <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <LinearLayout android:id="@+id/headerLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout

Edit Text in ListActivity ListView loses focus when keyboard comes up

假装没事ソ 提交于 2019-12-17 10:53:29
问题 I have searched and searched for an answer to this question and everything that looked like an answer has not worked so I guess I will just ask. I have a couple of EditText boxes added to a ListView that is the basis to a ListActivity . When I set the windowSoftInputMode to adjustPan and click in an EditText it works until you click on it again and then the keyboard covers it up. When I use adjustResize it works except when the keyboard comes up the EditText loses focus and I have to tap on

Android EditText listener for cursor position change

巧了我就是萌 提交于 2019-12-17 10:40:47
问题 I have a dialog with EditText in it. The EditText is already populated when it is created. When the user places the cursor on or near certain parts of the text a Toast will pop up. My problem is listening for changes in cursor position. Another post asks the same question and the accepted solution was You can override onSelectionChanged (int selStart, int selEnd) to get notified about selection changes. If the cursor is moved, this is called as well (in this case selStart == selEnd)

Creating a custom editText with tag-like feature

跟風遠走 提交于 2019-12-17 10:28:51
问题 I've been searching around but could not find any answers to this. What I'm trying to implement is an EditText similar to the 'To' field found in the composing screen of the ICS gmail app. Here's an image describing what I want: I'm thinking of extending EditText and implementing my own custom EditText class but I'm not really sure how to do that or even if that's the best solution. Any thoughts? 回答1: Adapted the solution from this answer. Separates the input automatically when inserting a

EditText onClickListener in Android

╄→гoц情女王★ 提交于 2019-12-17 10:26:12
问题 I want an EditText which creates a DatePicker when is pressed. So I write the following code: mEditInit = (EditText) findViewById(R.id.date_init); mEditInit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(DATEINIT_DIALOG); } }); But when I press the EditText the action is the typical: a cursor waiting for typing text instead show the Dialog I want. 回答1: The keyboard seems to pop up when the EditText gains focus. To prevent this, set focusable