android-edittext

EditText with suggestion list below

99封情书 提交于 2019-12-21 03:08:15
问题 I want to implement a "Google instant" like list in my app. Having an editText on top and a list below it, that is updated every time the user types in a new character. Can you point me to the right direction? Is there any widget or anything that I could use or do I have to drop the list and recreate it each time the users types something? Thanks in advance Mike 回答1: Perhaps you are looking for an AutoCompleteTextView? 来源: https://stackoverflow.com/questions/4903763/edittext-with-suggestion

Dynamic data for Adapter attached to EditText

社会主义新天地 提交于 2019-12-21 02:55:19
问题 Is there a way to attach dynamic adapter to EditText? What I want is - when a key is pressed on EditText, my code to do a search in (some) custom store and provide suggestions (instead of static Xml-list or array). This store is not a database; I think CursorAdapter is for database results only. Example code snippets are welcomed. 回答1: I found the solution and posted the answer to this question. Write a custom SimpleCursorAdapter . Override runQueryOnBackgroundThread() method and return a new

How to make TextWatcher wait for some time before doing some action

别来无恙 提交于 2019-12-20 21:46:11
问题 I have an EditText to filter the items in the ListView below it, which may contain more than 1000 items usually. The TextWatcher is: txt_itemSearch.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { fillItemList(); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); The issue here is that with each letter typed by the user, the list is getting

How to disable Android Soft Keyboard for a particular activity?

房东的猫 提交于 2019-12-20 19:57:51
问题 I have an activity with one EditText where I need to input numbers only. Now, I have defined the Input Type for my EditText to be number only and have drawn up a pretty keypad for my user to use, however I also need to make sure the soft keyboard doesn't pop up for my user when they click on the EditText. I have tried hiding the keyboard through the manifest by adding android:windowSoftInputMode="stateAlwaysHidden" in my Manifest for the particular activity, but this doesn't work for me

TextInputLayout hint color

允我心安 提交于 2019-12-20 18:04:08
问题 I'm using new Google design library (com.android.support:design:22.2.0) and I have problem with android.support.design.widget.TextInputLayout . If I set its EditText programmatically, floating hint color is gray instead of accent color. It works if user fills field (EditText) itself or if he changes preddefined value of field. This is my code: <android.support.design.widget.TextInputLayout android:layout_height="wrap_content" android:layout_width="match_parent"> <EditText android:id="@+id

How to make an EditText selectable but not editable on Android Ice Cream Sandwich?

ⅰ亾dé卋堺 提交于 2019-12-20 17:30:02
问题 I have a ListView in Activity, and in each item , I insert an EditText for show my text. I need drag the handle to select text & copy the text, but can not edit text. On Android ICS, How can I do this? 回答1: text.setTextIsSelectable(true) requires API 11. For those using lower API's: In xml use: android:inputType="none" android:textIsSelectable="true" This will make your EditText uneditable but selectable. 回答2: I think you could override the onKeyDown() method, make it do nothing but return

How do i add words to the suggestions on top of the soft keyboard

允我心安 提交于 2019-12-20 14:43:27
问题 Is there any way to add words to the suggestions in the soft keyboard? For a specific Edittext field i would like to add a list of names to the suggestions that pops up on top of the soft keyboard in android 2.0. Does anyone know if this is possible? 回答1: Here is the source code of the soft keyboard. If you go through the code, you will see that it uses a Suggest class which inside has different dictionaries. If you want to add words for a specific EditText you would need to add and remove or

How to filter the input of EditText?

前提是你 提交于 2019-12-20 14:43:18
问题 I want to filter the input of an EditText , only digits and letters are allowed, first I use TextWatcher to deal with the last input character, but when you move the cursor or you past some content to the EditText , this method failed, now I want to know is there a way to filter the illegal input and give the user a feedback. 回答1: Add InputFilter to your EditText & provide a Toast for user . This code snippet will help you. InputFilter filter = new InputFilter() { public CharSequence filter

margin inside the edit text in android

▼魔方 西西 提交于 2019-12-20 10:59:10
问题 My question is : I have an EditText and I want set a margin inside the EditText, I mean margin for the content (the text) of the edit text, not a margin for a the view witch I can resolve by this attribute : android:layout_marginLeft . I need let some space before and after the text inside the EditText. I tried to set the padding, but doesn't work ! this is my xml code : <FrameLayout android:layout_width="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:layout

android edittext remove focus after clicking a button

徘徊边缘 提交于 2019-12-20 10:25:18
问题 I have an Activity with an EditText and a Button. When the User clicks on the EditText, the keyboard is shown and he can type in some Text - fine. But when the user clicks on the Button I want the EditText to be no more in focus i.e. the keyboard hides til the user clicks again on the EditText. What can I do to 'hide the focus' of the EditText, after the Button is clicked. Some Code I can add in the OnClick Method of the Button to do that? EDIT: <LinearLayout android:layout_width="fill_parent