android-edittext

Android EditText draw a divider line between its drawable and its text

风流意气都作罢 提交于 2019-11-29 12:36:15
问题 I have an EditText with a drawableLeft image. I need to add a vertical line in EditText right beside my drawableLeft like this example: Easiest way that I can think of is to add that line into my drawable image. But generally is there any other way to do this? 回答1: Create a rectangular rounded corner shape in res/drawable/shape.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="3dip" android:color="@android

Android EditText background text

爷,独闯天下 提交于 2019-11-29 11:49:35
问题 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? 回答1: The hint property will take care of that for you. 回答2: Use hint

Android edittext in listview loses focus on calling notifydatachanged

不羁的心 提交于 2019-11-29 11:47:52
问题 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

How to change the floating hint color of TextInputLayout if EditText inside is disabled

痴心易碎 提交于 2019-11-29 11:35:54
I am using EditText with TextInputLayout . I just want to change the floating hint color of TextInputLayout if the EditText is disabled. I tried with selector it is not working. <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:textColor="@color/darkGray" /> <item android:state_pressed="false" android:state_focused="false" android:textColor="@color/lightGray"/> </selector> There's one method called setHintTextAppearance(int styleId) in TextInputLayout class. You can use this method to set difference colors to hint text on basis of

Setting up EditText with “url” inputType

让人想犯罪 __ 提交于 2019-11-29 11:31:51
问题 I am trying to make an EditText such that when i click it a key board containing ".com" appears because a url is to be intered into the EditText . I tried to use this: android:inputType="textUri" but it is not working. How do i do it? 回答1: try this one <EditText android:id="@+id/edt" android:layout_height="wrap_content" android:layout_width="wrap_content" android:inputType="textWebEmailAddress" /> android:inputType="textWebEmailAddress" use this property for that. 回答2: You can use inputType

Push up content except some view when keyboard shown

不问归期 提交于 2019-11-29 11:21:17
问题 I have a layout that contains 5 EditText and a Button and a TextView at bottom. Now when I press an EditText then the keyboard will shown and all my View is push up. Now I don't want to push my TextView and Button to above keyboard, just only want to push up all EditText inside ScrollView to above keyboard. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_main" android:layout_width="match_parent" android

Android - default value in editText

烂漫一生 提交于 2019-11-29 11:15:31
问题 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 回答1: You can use EditText.setText(...) to set the current text of an EditText field. Example: yourEditText.setText(currentUserName); 回答2: There is the hint feature? You can use the setHint() to set it, or set it in XML (though you probably

How do listen EditText?

风格不统一 提交于 2019-11-29 10:57:56
I have a EditText . I wamt tp do something, when the user presses the Enter key while changing EditText . How can I do that? The most simplest method: final EditText edittext = (EditText) findViewById(R.id.edittext); edittext.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show(); return true;

How to capture onclick event in disabled EditText in Android App

狂风中的少年 提交于 2019-11-29 10:33:49
问题 I have a EditText which I am presenting as disabled so that user cannot edit the contents and also to avoid popping-up keyboard. But now I want to capture onclick event in the EditText and identify the individual words that are being clicked. Any help is most welcome. Thanks, Balkrishna. 回答1: On your EditText set attributes android:focusable="false" and android:enabled="true" . And set OnClickListener to that EditText . The click on that Edittext triggers the onClick() method but it can't be

onCreateContextMenu() for EditText doesn't work on real device

二次信任 提交于 2019-11-29 10:28:08
问题 Just tried to test my app on real device (HTC Desire Z with Android 2.2). And found that my context menus doesn't work at all on EditText s. Otherwise context menus works: in ListView , ImageView and so on. On emulator everything works fine... When I tap on EditText it shows something like zoom frame and then shows unusual (not standard Android alike) context menu which reads: "select text", "select all". It doesn't show my menus. Here are screenshots: Before tap During tap After tap (just