android-edittext

Phone number format in android

六眼飞鱼酱① 提交于 2019-11-29 23:25:36
问题 In my application, I have a editText which will accept phone number from the user, My target is, as soon as user enters the phone number it should be formatted (Like by applying on text changed listener) , format is like XXX-XXX-XXXX . I wrote the code as ePhone.addTextChangedListener(new TextWatcher() { private Pattern pattern; private Matcher matcher; String a; @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub boolean

EditText doubling out on rotate

梦想的初衷 提交于 2019-11-29 23:01:14
I'm having an issue with an EditText control. This issue is only happening on this particular Activity and no other Activities with EditTexts. I have removed all setText calls for this EditText and the problem still persists. I am running Android 2.3.4 on my mobile device. It is a Nexus S and running stock Android. In the emulator (running Android 2.2) this problem does not occur. When I rotate the phone, Android automatically replaces the text that was in the EditText before the rotation. I'm not using savedInstanceState to do anything. Android is doing this itself. My problem: Suppose the

Hide soft keyboard on application load

感情迁移 提交于 2019-11-29 21:24:49
I have an application with an EditText element on the main view. This means that when my application is loaded the soft keyboard appears per default. I would like to be able to hide the keyboard on load, so it does not show until i tap on the EditText view. How do i manage this? neteinstein You can do something easier. Add this to the LinearLayout (or any other layout that is the root): <LinearLayout ... android:focusable="true" android:focusableInTouchMode="true" ... /> In your AndroidManifest.xml : <activity android:name="com.your.package.ActivityName" android:windowSoftInputMode=

Disable auto focus on edit text

≯℡__Kan透↙ 提交于 2019-11-29 20:24:31
I have an edit text: <LinearLayout android:id="@+id/linearLayout7" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:id="@+id/editText1" android:text="3"> <requestFocus></requestFocus> </EditText> <Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button2"></Button> </LinearLayout> and then some other stuff underneath The problem I'm having is that right when the app starts the focus is

AppCompat and EditText different underline on different API

梦想的初衷 提交于 2019-11-29 19:57:52
问题 I'm trying to make underline line color change for EditText (it will be used for input's validation, so it must be able to change in runtime). I'm using AppCompat library. The problem is that on API 21 and above, I see transparent black line (gray overlay), instead of bolded version. How to make it the same as in API 16? I used this code to change tint: final Drawable originalDrawable = view.getBackground(); final Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable);

Android - EditText on status notification

这一生的挚爱 提交于 2019-11-29 19:39:42
问题 Does anyone know if I can insert an EditText (for inserting text) on an Android notification? I would like to have a button and an edittext when the button is pressed then get back the text on the edittext. It's possible? Thanks 回答1: This can be done in Jelly Bean but as far as I know not in version prior to that. Since this is built in to the android system it should be considered and acceptable practice. From the android blog: Bi-directional text support: Android 4.1 helps you to reach more

How to change EditText cursor height?

丶灬走出姿态 提交于 2019-11-29 19:10:49
问题 I want to change the EditText cursor height, does anyone know how? 回答1: I had to dig far into the Android source to find the answer to this, but you essentially have to use padding on a custom shape drawable. note: only works on API 12 and greater due to support for textCursorDrawable Use positive top padding to move the top of your cursor higher User positive bottom padding to move the bottom of your cursor lower I usually end up using negative bottom padding to shorten the cursor because

HTML.fromHtml line breaks disappearing

自闭症网瘾萝莉.ら 提交于 2019-11-29 18:17:42
问题 I am taking Spanned Text from an EditText box and converting it to a HTML tagged string using HTML.toHtml. This works fine. I have verified that the string is correct and contains a <br> in the appropriate location. However, when I got to convert the tagged string back to a spanned text to populate a TextView or EditText using HTML.fromHtml the <br> (or multiple ones if they are present) at the end of the first paragraph disappear. This means that if a users entered text with multiple line

How to make my edit text type right to left ?

女生的网名这么多〃 提交于 2019-11-29 18:11:59
I actually wand to type Arabic,Is it possible ? I am creating an android application.And i am new to it.please help. i tried these code it didn't work. if(UTILSSessionVariables.LCID==2057) { setContentView(R.layout.passportdocumentfields); LastName.setGravity(Gravity.LEFT); } else if(UTILSSessionVariables.LCID==3801) { setContentView(R.layout.arabicpassportdetails); LastName.setGravity(Gravity.RIGHT); } Use a Bidi object to get the information on the position reordering of a bidirectional text, such as Arabic or Hebrew. The natural display ordering of horizontal text in these languages is from

Error inflating class EditText on creating TextInputLayout on Android 4.4.2:

我的梦境 提交于 2019-11-29 17:34:29
问题 I using the TextInputLayout UI mechanism in my login page of the application, everything works great except for device that run the 4.4.2 android version on this devices I have an exception. This is my layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <include android:id="@+id/loginInfiLogoRL" layout="@layout/login_infi_logo_layout" android:layout