android-edittext

How can we override getText method in EditText?

不羁岁月 提交于 2019-12-11 08:59:06
问题 I have override this method in MyEditText class: @Override public Editable getText() { Editable s = (Editable) super.getText(); s.toString().replace("$", "").trim(); return s; } MainActivity class is: public class MainActivity extends Activity implements OnClickListener { MyEditText myEditText; Button btn; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.try_layout); myEditText = new MyEditText(this); btn =

Change cursor color of an Editext for below 3.0 version

十年热恋 提交于 2019-12-11 08:34:32
问题 I want to change the android's edittext cursor color.I have used android:textCursorDrawable property but it supports only API level 12 or above.but my project minSDKVersion is 9 .So how can i change cursor color in below API level 12 . 来源: https://stackoverflow.com/questions/27814373/change-cursor-color-of-an-editext-for-below-3-0-version

alertdialog - removeView has to get called

ぐ巨炮叔叔 提交于 2019-12-11 08:17:31
问题 I have a alert dialog with a editText area. When I call it a second time, the app crashes with error: 02-28 23:25:08.958: E/AndroidRuntime(11533): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. Here is my code: alert = new AlertDialog.Builder(this); String txt_title = context.getResources().getString(R.string.txt_head_search_coord); String txt_message = context.getResources().getString(R.string.txt_mess_search

Updating Android EditText's hint on focus change using XML only

心已入冬 提交于 2019-12-11 08:05:10
问题 I read with interest user sunit's answer to this question about updating an EditText's hint but have been unable to find any documentation on using the method that I presume he appears to describe there: using the <selector> element in an XML layout to dynamically adjust attributes of an EditText at runtime when the element is focused/unfocused. In my case I am actually more interested in adjusting the android:inputType element (because the hint disappears for me when the inputType is

Disable SoftKeyboard in MultiLine EditText android

邮差的信 提交于 2019-12-11 07:44:14
问题 I am trying to paste clipboard content in a disabled EditText with no softkeyboard popup, with following code clipboardBox.setInputType(InputType.TYPE_NULL); android EditText does not respect line feeds, i.e. doesnt show multiline content and puts it in single line. I want to disable softkeyboard from popping up in a multiline content holder disabled EditText 来源: https://stackoverflow.com/questions/4225027/disable-softkeyboard-in-multiline-edittext-android

Changed text at the runtime in textview but after relaunching application retrieving default data in textview in android

a 夏天 提交于 2019-12-11 06:43:55
问题 I am using Shared Preferences to store data which is came from EditText and set preferences data back to TextView but when i reopen my application textview shows default value. How can set changed data to the TextView and data should not be lost after reopening application. I tried onSaveInstanceState() and onSaveInstanceState() but this works when orientation change of application. Here in my code i store data into shared Preferences and getting that data back to the TextView PRESET_MESSAGE

EditText focus disappears, when the barcode scanner reads the barcode

此生再无相见时 提交于 2019-12-11 06:35:52
问题 I need to read a barcode for an application. I am using trigger barcode scanner for this. Communication is via USB. As you know, barcode scanners work like keyboards. When the device reads the barcode, it tries to write the value to the input that has focus. And the user presses the trigger, the barcode scanner works until the barcode is read successfully. Then it takes itself in standby mode. Ideal way to read a lot of barcodes. The problem is that after the user presses the trigger and

EditText with a permanent hint in Java

落爺英雄遲暮 提交于 2019-12-11 06:29:07
问题 I have an EditText with some information in it. When there is no information, I'm displaying a caption using setHint() . final EditText info = new EditText(activity); if (data.getinfo() != null && !data.getAddress().trim().equals("")) { info.setText(data.getinfo()); } else { info.setHint(R.string.info); } I want to show that caption even if the EditText has info, the info should be below the caption. I tried using setText() . But that didn't work either. if (condition) { info.setText(R.string

android editText limit string length not by characters

我是研究僧i 提交于 2019-12-11 06:23:16
问题 I need to make sure the input string can fit the line where I'm going to show it. I already know how to limit the number of characters but that is not very good because 2 strings with the same character length have differente size... For exemple: String1: "wwwwwwwwww" String2: "iiiiiiiiii" in android string1 is much larger than string 2 because "i" consumes less visual space than "w" 回答1: You can use TextWatcher to analyse text being entered and Paint to measure the width of the current value

how to change text in a TextView dynamically based on another TextView

左心房为你撑大大i 提交于 2019-12-11 06:18:01
问题 Good morning everyone. I know from the title it's everything confused, so I will try to explain it better. I need to create an app for a medical project to calc HbA1c. I have 3 editText in which I type values of medical test. Each of three changes because of other one. For example: if I have 42 in one, the other one is 5.99%. And so on. I'm trying to make them change dynamically: change still during I'm writing. I tried using an OnCliclListener but I have to write the entire value. I don't