android-edittext

android - how to convert int to string and place it in a EditText?

Deadly 提交于 2019-12-03 05:36:19
问题 I have this piece of code: ed = (EditText) findViewById (R.id.box); int x = 10; ed.setText (x); It turns out to be an error. I know I have to change it to string, but how do I do this? I've tried x.toString() , but it can't be compiled. 回答1: Use + , the string concatenation operator: ed = (EditText) findViewById (R.id.box); int x = 10; ed.setText(""+x); or use String.valueOf(int): ed.setText(String.valueOf(x)); or use Integer.toString(int): ed.setText(Integer.toString(x)); 回答2: try Integer

TextInputLayout hint color

白昼怎懂夜的黑 提交于 2019-12-03 05:28:41
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/register_username" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="

Why my EditText copy/paste menu is under the EditText? How change the z-order of popup window?

爱⌒轻易说出口 提交于 2019-12-03 05:18:26
NOTE If someone know how to order (z-order) Windows added via windowmanager, i will also accept the answer because it's will answer all the question. Actually i only find to do windowManager.removeView(MyView) following immediatly by windowManager.addView(MyView) to put a view in front of the other, but this is not ideal because it's visually remove and add the view. it's look crazy that their is no build in function in android to do such a simple think. I create a view (linearlayout) that contain an EditText. I add this view in the activity via WindowManager.addView (view, Layout_Params); but

Android OS bug with some devices running Jelly Bean/4.2.1 - TextView.setError(CharSequence error) Missing icon

好久不见. 提交于 2019-12-03 05:00:00
问题 Some, but not all, devices running Jelly Bean (4.2.1) appear to be missing the exclamation point error icon that should appear on a TextView (or, more commonly, an EditText ) that has an error set on it via TextView.setError(CharSequence error). The Galaxy Nexus definitely seems to be missing the icon. The effect is that the error status set by setError is only apparent when the EditText has focus. This makes setError(...) much less useful as it's often used to encourage users to return to

How to hide softkeyboad when activity start in android?

巧了我就是萌 提交于 2019-12-03 04:14:19
问题 I have android app in which one layout contains Linearlayout , ScrollView , TextView , EditView and Button . when I call from one activity to other this activity call and set layout which I have describe. I would like to know when activity call there is by default EditView selected. and open the softkeyboard . I don't want to open that keyboard when activity start. but I want to open that softkeyboard on touch event of EditView . How can I do that? 回答1: In your AndroidManifest.xml : <activity

How to Get Text and Smiley from Edittext into String?

北战南征 提交于 2019-12-03 03:39:35
How to Get text and smiley from edittext into String? Using Following Code I was Add Smiley/Emojis in Edittext but how to get text/smiley from edittext into String Format. ImageGetter imageGetter = new ImageGetter() { public Drawable getDrawable(String source) { Drawable d = getResources().getDrawable( R.drawable.happy); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } }; cs = Html.fromHtml( "<img src='" + getResources() .getDrawable(R.drawable.happy) + "'/>", imageGetter, null); edttxtemoji.setText(cs); Please use following function. public static Spannable

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

為{幸葍}努か 提交于 2019-12-03 03:38:53
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? Macarse 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 change freq of a certain word from those dictionaries. Some issues: I couldn't find a way to get

Android Edittext with auto detection of credit card type

ぐ巨炮叔叔 提交于 2019-12-03 03:33:09
I am dealing with payment option in android, By give an option to make a payment with credit card, some of the users may mistakenly choosing different credit card type for some other credit card number, so i decided to take a look for this issue to auto detect the card type based on number entered, I found Flipkart have this already in their android application, here i attach that functionality, how to do this like a animation happening while changing the card type? I know to make a text watcher and based on the input to change the card type with a drawableRight image for EditText. But need to

editText field is required before moving on to another Activity

社会主义新天地 提交于 2019-12-03 02:44:25
问题 I have validation for editText . If the editText field is empty it should fail validation and stop the user moving on to another Activity , as a value is required. How to do it? I know this is a basic question, but I can't figure out how to do this. My code: btninsert = (Button)findViewById(R.id.btn_insert); btninsert.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { insertValues(); EditText userName = (EditText) findViewById(R.id.editText1); if( userName.getText(

Detect delete button in soft keyboard

邮差的信 提交于 2019-12-03 02:43:31
I have two EditText (each only only accepts one character) and I want to handle both fields like I had only one. I'm using a TextWatcher to set the focus in the second one when the user writes a character in the first one, but I don't know how to do the opposite. If the user press the delete button in the second EditText (being this EditText empty) I want to move the focus to the first EditText and delete the character there. The problem is that TextWatcher doesn't work when the user tries to delete an empty field (because in fact nothing is changing). And onKeyDown event only works with hard