android-edittext

Android EditText Gmail like to field

邮差的信 提交于 2019-12-17 10:16:56
问题 I'm working at an app, and I'm trying to make a gmail like "To" field, which has blocks inside which cannot be edited once added, but just removed entirely (like in the attached image). If it can have an image too, that would be perfect. 回答1: This technique -- referred to as "chips" -- is discussed by Roman Nurik in a Google+ post. He, in turn, points to Macarse's answer here on StackOverflow. They, in turn, point to the implementation of this UI that you see in the stock messaging client.

How to disable spelling corrections programmatically in Android

主宰稳场 提交于 2019-12-17 09:47:34
问题 How can I disable spelling corrections in an EditText 's soft-keyboard programmatically in Android? The user can disable it from settings, but I need to disable it in my application. Is there any way to do this? 回答1: Set this in your layout's xml for your EditText: android:inputType="textNoSuggestions" Or call setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) in your Activity' If you need to support API 4 and below, use android:inputType="textFilter" 回答2: If setting: android:inputType=

Add drop shadow effects to EditText Field

自古美人都是妖i 提交于 2019-12-17 08:54:10
问题 I am trying to design an EditText Field having Shadows (bottom and right side) like this tried googling & hunted many SO discussions but all are for TextView not EditText. This is my code adding shadow to Input Text but not to TextField <EditText android:id="@+id/txtpin" android:maxLength="4" android:layout_marginLeft="10dp" android:layout_height="37dp" android:gravity="center_horizontal" android:inputType="textPassword" android:longClickable="false" android:layout_width="160dp" android

Stop ScrollView from auto-scrolling to an EditText

一个人想着一个人 提交于 2019-12-17 08:23:41
问题 Seems to be a common problem without a great solution that I have found. Goal is to stop a ScrollView from auto-scrolling to an EditText (or any view for that matter) that has focus. You have a bunch of views ( Button s, TextView s, etc) in an ScrollView , one of which is an EditText . Upon clicking say a Button within the ScrollView , the ScrollView scrolls down to the EditText (its off screen). This is not desired, as there are other elements that you don't want scrolled off the screen. Now

Android different EditText backgrounds for different states using shapes, selector or list

不想你离开。 提交于 2019-12-17 07:48:27
问题 I'm starting a new app where I use ActionBarSherlock & HoloEverywhereLib. My min & target SDK are the same (10/2.3.3). This is just so I can also quickly port it to Amazon Kindle & BB10 using the android runtime they have (already used this setup for another app and it worked without issue). All the while the app should have as close to ICS/JB look as possible. For my EditTexts though, I'm giving them a Girgerbread/iOS (round corners, but no shadows) look to them Someone mentioned to me a few

How to do something after user clicks on my EditText

烈酒焚心 提交于 2019-12-17 07:17:13
问题 I have an EditText that shows time. After user clicks the EditText I want to show a TimePickerDialog , so I set a View.OnClickListener to my EditText . But the OnClickListener is behaving weirdly - I touch the EditText and then software keyboard appears (which I don't want). When I touch again, OnClickListener.onClick() is finally called and the dialog appears. What should I do if I want the dialog to appear immediately? 回答1: Unlike most other controls, EditText s are focusable while the

set textCursorDrawable programmatically

倖福魔咒の 提交于 2019-12-17 07:16:13
问题 If I add an EditText in XML I can set textCursorDrawable="@null" : <EditText android:id="@+id/txtE3Casecode4" android:layout_width="30dp" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:background="#C7C7C5" android:textCursorDrawable="@null" android:ems="10" android:inputType="number" android:maxLength="2" android:text="01" android:textColor="#000000" /> Now I draw an EditText in Java. I want set android:textCursorDrawable="@null" . LinearLayout.LayoutParams

Android TextField : set focus + soft input programmatically

你离开我真会死。 提交于 2019-12-17 07:11:29
问题 In my view, I have a search EditText and I would like to trigger programmatically the behaviour of a click event on the field, i.e give focus to the text field AND display soft keyboard if necessary (if no hard keyboard available). I tried field.requestFocus() . The field actually gets focus but soft keyboard is not displayed. I tried field.performClick() . But that only calls the OnClickListener of the field. Any idea ? 回答1: Good sir, try this: edittext.setFocusableInTouchMode(true);

Get Cursor Position in Android in Edit Text?

北战南征 提交于 2019-12-17 07:11:15
问题 I am using a custom EditText View. I have overridden the OnKeyUp event and am able to capture the Enter Key press. Now my requirement is, when the user has entered a text "Hi. How are you?" and then keeps the cursor after the word "are" and press enter, I need to get the cursor location so that i can extract the text after the cursor at the moment the Enter Key was pressed. Please let me know how to do this. Thank you for your time and help. 回答1: You can get the Cursor position using the

Dynamically add textViews to a linearLayout

ε祈祈猫儿з 提交于 2019-12-17 06:29:50
问题 I read this somewhere here and I totally lost it, but could use some assistance. My app is pulling the column names from sqlite into an array. I want to create a textview and edit text for each one (via the size of the array), and I remember reading somewhere that you can treat the textViews variable names like an array, but I don't know where that is now. So how would I dynamically create a textView and editText for however many listings are in an array? It was something like TextView tv[] =