android-edittext

Add input constraints to Edit Text in Android?

五迷三道 提交于 2019-12-22 13:48:00
问题 I have condition where it is required to enter some numeric values in the application. Cases: If user enters whole number then the max length should be 8 digits. Eg: 12345678 If users wants to enter decimal value he can only input upto 2 decimal points. Eg: 1.03, 123.95 If users enters whole 8 digits then he can also input the decimal places upto 2 decimal points. Eg: 12345678.12 So we have the following valid inputs: 1. 12345678 2. 123.45 3. 12345678.98 How can I achieve the above case

Show password characters for a short while before hiding them

蓝咒 提交于 2019-12-22 12:58:31
问题 In my application I've implemented a num-pad of my own, which is used for entering (number-based) passcodes. The 'password', or rather the 'dot'-representation of it, is shown on 4 EditTexts implemented in 4 boxes above the num-pad. When you enter a number one of those boxes will get filled in with a dot - for this I use the TransformationMethod PasswordTransformationMethod - but I'd want the number you punch in to be visible for a short while before it gets hidden (Like ~200ms). Is there any

Android views' borders issue on some devices

心已入冬 提交于 2019-12-22 12:38:15
问题 TOPIC Solved: Answer below. Some users have been reporting border alignment issues on some android components such as the alert popup or the editTexts. This is happening on the Samsung Galaxy Apollo (200x400) and the HTC Pro Touch (480x640) devices. I cannot replicate that because i don't own those devices and in the Samsung Galaxy S and emulator everything looks just right. I think that the problem is the dpi or resolution of the device (because the edittext background is a single .9.png so

Android EditText's cursor coordinates (absolute position)

心已入冬 提交于 2019-12-22 10:48:33
问题 How can I get the coordinates of the cursor in the EditText ? I am not trying to get the cursor position here but the EditText coordinates of the cursor. In my case, when I send a number via KeyEvent to the EditText, the cursor position (getSelectionStart) is changed, but its location is always at the right of the EditText. I want to know the coordinates of the cursor (the right of the EditText). 回答1: It's a little bit late answer :), but from API level 21 (Lollipop) there is a way to do it:

Subclass of EditText isn't behaving like EditText

随声附和 提交于 2019-12-22 10:46:43
问题 I've written a subclass of EditText . Here is that subclass: package com.package.foo; import android.content.Context; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.EditText; public class FuturaEditText extends EditText{ public FuturaEditText(Context context) { this(context, null, 0); } public FuturaEditText(Context context, AttributeSet attrs) { this(context, attrs, 0); } public FuturaEditText(Context context, AttributeSet attrs, int defStyle) {

Is there any way to automatically set the all layouts to support for both RTL and LTR direction types of languages in android

℡╲_俬逩灬. 提交于 2019-12-22 10:46:00
问题 I am new in android development, stuck to change the language of the whole android application. i found a way to set the strings into strings-languagecode in values directory and android:supportsRtl="true" in manifest file, it is good for changing the value of the text fields and their direction LTR and RTL automatically but I am getting the problem in EditText field because it's direction needs to be changed and set by the Java code for every xml file. Is there any way to set the direction

How to restrict the EditText input content

删除回忆录丶 提交于 2019-12-22 10:01:11
问题 I am trying to create a simple calculator which provides the EditText for the users to input the numbers. The allowing input content should be [1,2,3,4,5,6,7,8,9,0,.] I know that it is possible to limit the input content by using following code android:digits="1234567890." android:inputType="phone" But how can I prevent the users from adding more than one dot ( . ) into the EditText Box? 回答1: You can use this digits attribute android:digits="0123456789" 回答2: You can use InputFilter limit

Display non-editable text at end of EditText in android

こ雲淡風輕ζ 提交于 2019-12-22 09:59:44
问题 I want to display text at the end of EditText as shown in the image above for URLName.How could I acheive this ?The text cannot be edited.I am using this editText inside TextInputLayout from the design library. thanks in advance 回答1: Create a LinearLayout . An example of a row inside this layout would be a title (i.e. URL name) or a text entry field. Set the background of the LinearLayout for the current row to a custom drawable to create a thin red line. Follow the answers on this post for

EditText with non-selectable grayed out prefix

∥☆過路亽.° 提交于 2019-12-22 09:55:04
问题 I'm looking for a way to have a grayed out text as prefix in an EditText. This text should be not selectable. It's a bit like the To field when you're composing a message with Gmail. The only (visual) difference is that this text disappears when you start typing. Is there any trick to achieve this in Android? Thanks! 回答1: As an ultimate solution, you can rewrite the full EditText class by extending it and modifying it in a way that it has a custom Background set by you, and a predefined

Get word from EditText on current cursor position

自古美人都是妖i 提交于 2019-12-22 09:17:05
问题 I am new to android programing. I added a context menu to edittext. I wish I can get word under cursor on long press. Help Please. I can get selected text by following code. @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { EditText edittext = (EditText)findViewById(R.id.editText1); menu.setHeaderTitle(edittext.getText().toString().substring(edittext.getSelectionStart(), edittext.getSelectionEnd())); menu.add("Copy"); } edittext have some text e.g