android-edittext

Android Error inflating class EditText

二次信任 提交于 2019-12-10 15:14:59
问题 I encountered a strange problem. My Android app would crash whenever I add an EditText in an Activity . To test, I open a new clean project, and the new project will crash if there is an EditText as well. Therefore, I think the problem is caused from Android Studio or other environment setting. Following is the activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res

A better way to OnClick for EditText fields?

回眸只為那壹抹淺笑 提交于 2019-12-10 15:13:45
问题 I have an EditText field, suppose the user has already entered text into it. Then the user wants to come back to edit the text again: the feature I want for this EditText field is that if you select it after it already has text in it, it clears the text for you before you can type something new in. I tried using the EditText field's OnClick method, but this required that I select the EditText field, then click on it a second time, something that isn't obvious to anyone but me. How can I get

EditText setText not displaying on a Dialog Fragment

只愿长相守 提交于 2019-12-10 14:55:31
问题 I'm kinda new to Android app development, and don't know how to debug this. So I'm trying to do EditText.setText on a DialogFragment. It prints out the right string on the log, but still showing the old string based on .xml file("Enter item here."). Is there any way to update it? public class MyAlertDialogFragment extends DialogFragment{ public MyAlertDialogFragment() {} public static MyAlertDialogFragment newInstance(String desc) { MyAlertDialogFragment frag = new MyAlertDialogFragment();

Android: Adding decimal point to EditText field, and make it move with input

限于喜欢 提交于 2019-12-10 14:46:30
问题 In my app, the user is able to enter a dollar amount in a text field. The thing is, I need the input to adapt to the final number as they enter the digits, without actually entering the decimal point. The best way to explain this is with an example: Suppose the user starts off with an EditText field which contains this: . The user wants to enter $12.53 into the field (i.e. the digits 1,2,5,3). Then he/she starts by entering 1, and the field should look like this: .1 Then: .12 Next: 1.25

Incorrect EditText line spacing behavior in target API 28, when dealing with non-English Unicode (Like Chinese, Japanese)

爱⌒轻易说出口 提交于 2019-12-10 14:27:27
问题 We notice that, during targetSdkVersion 28, EditText will tend to "slightly push down" the line after input, when non-English unicode (Like Chinese, Japanese, ...) is being entered. Such behavior doesn't happen, when the code is targetSdkVersion 27 or below. Use targetSdkVersion 27, run on emulator API 28 (Before input non-English unicode) (After input non-English unicode) (Confirm spacing is OK) Use targetSdkVersion 28, run on emulator API 28 (Before input non-English unicode) (After input

How to store the data from edittext to android sqlite database?

不羁的心 提交于 2019-12-10 14:12:07
问题 I am a new developer on Android and I want store user data in database using sqlite. For that design .xml file username as edittext and take button, after fill all text fields when click the button all the data is stored in database. and show this data on screen..... 回答1: These are useful tutorial and will help you http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/ http://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Android-Cursors/1/ http://developer.android

Capitalize every word in Edit text while typing

假如想象 提交于 2019-12-10 13:54:32
问题 I want to capitilze every word in edit text while typing. My XML:- <com.project.edittext.AutoFitEditText android:id="@+id/txt_name" style="@style/scan_text_fields_white_bg" android:layout_width="match_parent" android:layout_height="wrap_content" android:digits="@string/validation_accept_all_except_special_char" android:fontFamily="sans-serif" android:imeOptions="flagNoExtractUi|actionDone" android:inputType="textNoSuggestions|textCapWords" android:maxLength="50" android:paddingBottom="3dp"

TextWatcher onTextChanged not working with soft keyboard auto-complete / suggested words

半世苍凉 提交于 2019-12-10 13:35:25
问题 I'm Implementing a TextWatcher on an EditText to find and underline a series of keywords within the text whenever a new character is entered by the user. However when a suggested / auto-complete word on the soft keyboard is selected, instead of adding the suggested word to the Edittext and then calling the onTextChanged function the half complete word is deleted. I found this rather strange as entering individual characters activates the onTextChanged function just fine. Any help would be

Android How to set maximum “word” limit on EditText

假装没事ソ 提交于 2019-12-10 13:17:43
问题 How to set maximum word limit on Android EditText I know how to set character limit but I am looking for Word Limit . 回答1: You need to add a TextChangedListener to your EditText then apply an InputFilter see the following code. edDesc.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { int wordsLength = countWords(s.toString

How to know if keyboard (dis)appears in Android?

被刻印的时光 ゝ 提交于 2019-12-10 13:05:30
问题 I have an EditText and want to give it more lines when the keyboard appears. So i am looking for something like a "OnKeyboardAppearsListener" but can't find it. I think it must exist, but perhaps in a different way... 回答1: You have to @Override onConfigurationChanged to be able to handle runtime changes: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks whether a hardware or on-screen keyboard is available if (newConfig