android-edittext

Can I use the soft keyboard without an EditText?

泪湿孤枕 提交于 2019-11-30 08:26:05
I'm creating a simple typing game in Android. I have no problem getting input from the physical keyboard, but now I'm trying to get the soft keyboard to appear without the EditText. So far, I've tried the following: 1. EditText with visibility="invisible" and this line: ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(keyboard_edittext, InputMethodManager.SHOW_FORCED); // SHOW_IMPLICIT also failed 2. This line in the onCreate() : this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); This method actually displayed an

Android EditText background text

亡梦爱人 提交于 2019-11-30 08:25:44
Is there a way to set the background text of an EditText? for instance, I have a login screen with 2 EditText views, one for username and one for password. I want the text "Username" and "Password" be written inside the EditText, and once the user touches those the text disappears but once user deleted his own entry, text re-appears. Is there a property for that or should I implement this on my own with events and stuff? The hint property will take care of that for you. Use hint property, or setHint method. 来源: https://stackoverflow.com/questions/4489646/android-edittext-background-text

How do I position the cursor on the right in EditText

北城以北 提交于 2019-11-30 08:18:14
My application uses RTL language (right to left). When the EditText field gets focus, the cursor appears on the left and only when the user starts to type, the cursor (and the RTL text) moves right. When the user clicks "enter" to start a new line, the cursor moves to the left again. When I use android:gravity="right" , the cursor is OK (on the right) but as the user starts to type the text always moves to the the other side (RTL text moves left). Any ideas how I can align text to the right AND keep the text direction? Its works for me <EditText android:id="@+id/editText1" android:layout_width

How does Kotlin property access syntax work for Java classes (i.e. EditText setText)?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 08:16:15
I'm trying to switch my Android project to Kotlin. I have an EditText (a subclass of TextView ) for which I want to set a hint and text programmatically. The hint works as expected. For text, though, I'm getting a type mismatch exception if I try to do it using Kotlin setter syntax: val test = EditText(context) test.setHint("hint") // Lint message: "Use property access syntax" test.hint = "hint" // ok test.setText("text") // ok (no lint message) test.text = "text" // Type mismatch: inferred type is kotlin.String but android.text.Editable! was expected If we look at the declaration, we'll find

Android edittext in listview loses focus on calling notifydatachanged

蹲街弑〆低调 提交于 2019-11-30 08:12:33
I have a few edittext within a listview. i have a generic focuslistener on the edittext that updates the value of the data model and also the background of the edittext when focus is lost by calling notifydatachanged . The problem is that if one of the edittext is holding focus, when i touch the next edittext, it gains focus momentarily then loses focus. I suspect it is due to the notifydatachanged method call that is causing all views to be redrawn, after which the focus is lost. Does anyone have a suggestion or work around on the issue? Thanks. It is indeed happening because all the views

Enable and disable Button according to the text in EditText in Android

给你一囗甜甜゛ 提交于 2019-11-30 08:01:03
问题 I want to disable by Button if the words in the EditText is less than 3 words, and if the words in the EditText are more than 3 words then I want to enable it so that it can get Clicked. Can anyone help me here? 回答1: You have to addTextChangedListener to your EditText Like this: yourEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count,

Android - default value in editText

给你一囗甜甜゛ 提交于 2019-11-30 07:57:22
In my app I have an edit user details page and I want to display the current name, email address etc in the corresponding editText fields and then the user can just erase that and enter a new one if they want. Is there a way to do this? Thanks for any help You can use EditText.setText(...) to set the current text of an EditText field. Example: yourEditText.setText(currentUserName); There is the hint feature? You can use the setHint() to set it, or set it in XML (though you probably don't want that, because the XML doesn't 'know' the name/adress of your user :) ) From the xml: android:text=

EditText how to activate copy/paste popup without any actionbar?

大城市里の小女人 提交于 2019-11-30 07:53:42
问题 I m under delphi and i use the android framework to create an edit. When i set the theme to Theme.DeviceDefault.Light.NoActionBar then i can select some text in my EditText and i have a popup with "select all/cut/copy/paste/etc" like you can see on the picture below. However, when i select Theme.Material.Light.NoActionBar or Theme.Holo.Light.NoActionBar then i can't select any text in my EditText (i have no right or left text selection handles) and off course i don't have any copy/paste popup

Android EditText + set some words in colour

送分小仙女□ 提交于 2019-11-30 07:53:19
问题 I create EditText boxes dynamically, depending on what is pulled back from the database. Ie. final EditText textV = new EditText(this); textV.setText(monEntry); Is there anyway to set some of the text in the EditText to one colour and another bit to another without using a subString()? Thanks alot if anybody can help! 回答1: Yes, you can have different colors in different places of the text if you are using SpannableString. Example: SpannableString text = new SpannableString("Lorem ipsum dolor

Android ScaleAnimation doesn't scale clickable area

夙愿已清 提交于 2019-11-30 07:52:58
I have a layout structured as follows: LinearLayout1 LinearLayout2 EditText I am applying a ScaleAnimation to LinearLayout1 using a LayoutAnimationController so that all of the views in the hierarchy are scaled by the same amount. After applying the ScaleAnimation, the views are all scaled correctly, but the EditText no longer responds to clicks that fall outside the space it originally occupied. In other words, it appears that the clickable area for the EditText does not scale along with the visual representation. Is there a solution to this problem or I am missing before or after calling the