android-edittext

How to show the numeric keypad

我是研究僧i 提交于 2019-12-03 08:40:44
问题 I read several other posts and using input.setInputType(TYPE_NUMBER_FLAG_DECIMAL); does open the keyboard but its not the numeric keyboard Is there a trick to this? 回答1: give android:inputType="number" inside your xml file Edit: "Number" does not work, changed to "number" (lowercase N) 回答2: a) in xml android:numeric="decimal" b) in code EditText editView = new EditText(this); editView.setKeyListener(new DigitsKeyListener()); 回答3: In your xml, you have to do this: android:inputType="Number" In

EditTextPreference Disable Buttons?

人走茶凉 提交于 2019-12-03 08:32:37
I want to have an EditTextPreference that will disable the OK button if there is no text in the EditText field. I created a custom EditTextPreference class and I am able to get the EditText object and set a TextWatcher, but I can't find a way to disable the button. It looks like I just don't have access to the OK and Cancel buttons in the Dialog. Anyone know a way to get at these buttons or to do what I am trying to do? Only other option is to try to create from scratch a custom Dialog that looks like and mimics the EditTextPreference. Here is a code sample that enables/disables button

How can EditText accept only integer or float value?

故事扮演 提交于 2019-12-03 08:29:47
问题 I am new to Android development. In my project, I’m using EditText, but I want to force it to only accept an integer or float value. How can I do that? 回答1: If you want to use Decimal Number only on your EditText use the xml attribute android:inputType="numberDecimal" in your EditText widget your EditText declaration will be like this: <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType=

How can I make links in an EditText clickable?

为君一笑 提交于 2019-12-03 08:17:41
问题 I have an EditText on Android I'd for which I'd like any embedded urls to be clickable. I used the Linkify class, which has turned them blue and underlined them. However, I can't figure out how to actually make them clickable. Thanks! 回答1: XML: android:linksClickable="true" android:autoLink="web|email" JAVA: TextView textView = (TextView) findViewById(R.id.textViewId); textView.setText(Html.fromHtml(html)); textView.setMovementMethod(LinkMovementMethod.getInstance()); 回答2: For edit text I

EditText in ListView is updated by onTextChanged when scrolling

懵懂的女人 提交于 2019-12-03 08:16:17
I have been searching for an answer to this, but the solutions don't seem to work for me. I have a TextView and an EditText in a list item. I am trying to update the stored values for the EditTexts when the user edits them. @Override public View getView(int index, View convertView, ViewGroup parent) { ViewHolder holder = null; final int pos = index; if (convertView == null) { convertView = mInflater.inflate(R.layout.user_details_list_row, parent,false); holder = new ViewHolder(); holder.mCaptionTextView = (TextView)convertView.findViewById(id.user_detail_row_caption); holder.mDetailEditText =

Android : Typeface is changed when i apply password Type on EditText

纵饮孤独 提交于 2019-12-03 07:21:15
问题 I use FloatLabel library (https://github.com/weddingparty/AndroidFloatLabel) to add a little animation when user begin to write something in an EditText Android. My problem is that the typeface seems to be changed when i apply the password type to my EditText. I would like to keep the same typeface as normal. (see picture 1) But when i add the following line to apply password type, the typeface of hint seems to be changed ! pass.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType

How to show an text editing box “over” the screen?

此生再无相见时 提交于 2019-12-03 07:15:10
问题 I have an application that has a primary layout of portrait (it is fixed as portrait), and there is one place to type in text. I would like to launch like a popup window in landscape orientation with the background image fogged out. I know there is a Popup Widget, but any ideas for rotating the text edit box would be great. Rotating it into a portrait view (text box only) when the keyboard is slid out would also work, as would showing a new screen with the text box on keyboard slide. 回答1: The

Android EditText: How to disable cursor move on touch?

和自甴很熟 提交于 2019-12-03 06:31:18
I have EditText which displays something like ###-###. I want the user to be able to change this text only from the 1st position onward. That is user should not be able to touch a # in the middle and change it. How can I do this? Thanks a lot. Sorry, I was not precise in my question. I want to disable even tapping in the middle of the text. Following code will force the curser to stay in last position if the user tries to move it with a tap on the edittext: edittext.setCursorVisible(false); edittext.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext

ImageSpan on EditText (smileys). With SwiftKey Keyboard doesnt work

只谈情不闲聊 提交于 2019-12-03 06:23:28
问题 I am doing a simple chat application and i want to show smileys on edittext while writing the message. I have this to identify wich characters will be subsituted by an Image throught an ImageSpan (this is called only when an smileys character is inserted on EditText): for (index = start; index < start+num_chars; index++) { if (index + 1 > editable.length()) continue; if(emoticons.containsKey(editable.subSequence(index, index + 1).toString())){ int length=1; Drawable drawable = context

How to apply global custom style to android.support.design.widget.TextInputEditText?

二次信任 提交于 2019-12-03 06:21:35
I have my AppTheme defined in style.xml where I apply a custom style globally for all my app's TextView , EditText , Button etc. Now I'd like to do the same for android.support.design.widget.TextInputEditText but how? It does not extend EditText so that style is ignored. Here's what I've got: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary</item> <item name="colorAccent">@color/accent</item> <!-- Globally override default