android-edittext

How to comma-separate numbers in EditText

允我心安 提交于 2019-12-21 20:45:51
问题 I have an EditText that has an inputType of number . While the user is typing, I want to comma-separate the numbers. Here's a little illustration: 123 would be represented as 123 1234 would be represented as 1,234 12345 would be represented as 12,345 ...and so on. I tried adding a comma with TextWatcher as shown below: EditText edittext = findViewById(R.id.cashGiven); edittext.addTextChangedListener(new TextWatcher(){ @Override public void beforeTextChanged(CharSequence charSequence, int i,

How to show space key in softkeyboard and perform some action when user clicks on space key

你说的曾经没有我的故事 提交于 2019-12-21 20:39:11
问题 I have an edittext. In that edittext user enters some text. when user hits on space key, i need to perform some action. how can i do it. Thanks in advance. 回答1: To do something when the user presses the space key you use the following - if((event.getAction()==KeyEvent.ACTION_DOWN)&&(key == KeyEvent.KEYCODE_SPACE)){ //put your code for whatever you what to do when the user presses space here } } Problems intercepting space key in EditText If you have multiple edittexts, in the above code put

Android EditText onClick Listener defined in Layout fails with obscure Exception

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 14:49:30
问题 I want to define an onClick Listener for an EditText in the Layout-XML of may activity, but it always fails with an obscure Exception. The Layout is injected with setContentView() in the onCreate -Method of my activity. I am not using a Fragment here and I am well aware that the XML defined onClick Listener do not work for fragments. For testing purposes I added the same handler method to an ImageView that is located next to the EditText. There the handler works, on the EditText it fails. So

Android - How to only allow a certain number of decimal places

坚强是说给别人听的谎言 提交于 2019-12-21 12:56:59
问题 Do you know of any method to make sure users can only enter figures with a maximum number of decimals. I'm not sure how to address this problem. In the MS SQL database I'm going to send data from my app I've got columns with this type decimal(8,3) Now considering the data type of the column that's finally going to store the value I want to validate in Android, I've considered these two cases: If the user enters a number with no decimals, the maximum number of digits must be 8 If the user

progressDialog animations pauses on large setText()

这一生的挚爱 提交于 2019-12-21 12:27:32
问题 I'm trying to set a large text in a EditText, the operation can take over 30 seconds so I use a ProgressDialog. It shows up, but there's no animation, and then disappears when the operation is done. Here's my simplified code: class FileOpener extends AsyncTask<File, Integer, String> { private ProgressDialog progress; @Override protected void onPreExecute() { progress = new ProgressDialog(context); ... progress.show(); } @Override protected StringBuilder doInBackground(File... files) { return

EditText - Get text from EditText while typing

送分小仙女□ 提交于 2019-12-21 09:07:47
问题 I want to get the text into some String in my app while the user is typing in the EditText and use it to lively show it on the activity (in different View...) - Just like google's live/instant search works... 回答1: You are looking for TextWatcher : youredittext.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable mEdit) { text = mEdit.toString(); } public void beforeTextChanged(CharSequence s, int start, int count, int after){} public void onTextChanged

EditText inside ListView lost focus [duplicate]

扶醉桌前 提交于 2019-12-21 09:05:14
问题 This question already has answers here : Focusable EditText inside ListView (12 answers) Closed 6 years ago . I have recently face this problem and I want to share with you my solution. Problem : You have a ListView with a Edit Text for each row like this: MainList.xml <ListView android:id="@+id/listViewServ" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> RowList.xml <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android

Android: Display TextView in the right-side of EditText which is in the TextInputLayout

人盡茶涼 提交于 2019-12-21 08:02:06
问题 I am trying to create a layout like in the picture below In the above picture the password field is in the TextInputLayout and it also have a TextView in the right side , which points to the Forget Password Activity. I achive EditText with Textview without TextInpt layout like below using relative layout XML layout: <EditText android:id="@+id/email_address" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/ic_email" android:drawableStart=

Android: Display TextView in the right-side of EditText which is in the TextInputLayout

蓝咒 提交于 2019-12-21 08:01:37
问题 I am trying to create a layout like in the picture below In the above picture the password field is in the TextInputLayout and it also have a TextView in the right side , which points to the Forget Password Activity. I achive EditText with Textview without TextInpt layout like below using relative layout XML layout: <EditText android:id="@+id/email_address" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/ic_email" android:drawableStart=

EditText vs TextView

混江龙づ霸主 提交于 2019-12-21 06:48:45
问题 I read the API's and see that TextView is a super class to EditText , but I have a short and simple question: Generally speaking, EditText is used when the text displayed is subject to change, whether it's from the user or the app. TextView is used when the text displayed is to be constant/same forever. Is this correct? 回答1: If you have done any java projects before, I see Textview and EditText are just same as JLabel and JtextField . If you want to ask user to enter username you will set an