android-edittext

Dynamic leading text for android's EditText

淺唱寂寞╮ 提交于 2020-04-17 22:04:32
问题 I've looked into using a TextWatcher and an InputFilter , but I'm not too sure how to approach this problem. The idea is to have an EditText that inserts text from right to left. As the use input changes, I would like the following to occur. - User enters "1" -> Text formats as 00:01 - User enters "2" -> Text formats as 00:12 - User enters "8" -> Text formats as 01:28 How could I approach this? Inputfilter seems to be for excluding text and using setText inside the TextWatcher appears to run

How to limit specific character in edit text?

烂漫一生 提交于 2020-04-16 05:47:50
问题 My question is that How to limit specific character in edit text? for example I want to limit # character using max. 3 times in edit text. How can I do this? Any advice or code sample please. thanks. 回答1: use this yourEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(count>3){ yourEditText.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {

How to set the distance from soft keyboard to EditText?

走远了吗. 提交于 2020-04-13 05:42:27
问题 I have a problem with soft keyboard overlapping parts of EditTexts. When I click my EditTexts the soft keyboard appears just below the text, which means that a part of the text box is not shown as the soft keyboard overlaps it. Any ideas how to increase the distance between EditText and Soft keyboard? 回答1: There will be certain Solutions available that some times works and some times not what I am using is working and will handle your scenario Use the following Step by step 1- Add Scroll view

How to get text from EditText within ListView with multiple Views?

最后都变了- 提交于 2020-04-10 04:05:43
问题 I have a ListView that contains two TextViews and one EditText in each row. I have searched and searched and cannot figure out how to get the text that the user enters into the EditText. My most recent attempt implements a TextWatcher. public void addIngredientToMeal(String ingredientName) { ingredient_list = (ListView) findViewById(R.id.ingredients_in_meal_listView); int numberOfIngredients = ingredient_list.getChildCount(); ListAdapter adapter = new ListAdapter(); adapter.name_array = new

How to enable keyboard on touch after disabling it with setTextIsSelectable

假装没事ソ 提交于 2020-04-06 18:34:11
问题 I am using a custom in-app keyboard, so I need to disable the system keyboard. I can do that with editText.setShowSoftInputOnFocus(false); for Android API 21+. But to do the same thing down to API 11, I am doing editText.setTextIsSelectable(true); Sometimes I want to show the system keyboard again after disabling it with setTextIsSelectable . But I can't figure out how. Doing the following does show the system keyboard, but if the user hides the keyboard and then clicks the EditText again,

How to get Textinputlayout hint android in multiple lines?

让人想犯罪 __ 提交于 2020-03-18 11:16:23
问题 I have tried many options available online but none of them seem to be working. I have used this XML for this purpose. <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:hintTextAppearance="@style/TextLabel"> <com.projects.fonts.RobotoEditText style="@style/EditText" android:hint="@string/description" android:singleLine="false" app:font="@string/roboto_regular" /> </android.support.design.widget.TextInputLayout> I have

How do I set multiple input types in an EditText on Android?

北慕城南 提交于 2020-03-17 08:35:05
问题 I am trying to create an EditText with auto-capitalization and auto-correction implemented. I have manually figured out how to add InputFilter s to allow auto-capitalization, though this only works after the first letter is typed, and I have had no luck with auto correction (I tried to create an InputFilter that used AutoText , but I'm not sure how all that works). Ideally, I could just use EditText.setInputType(...) to handle everything, but so far this has not worked. Is there a way to

Textwatcher giving Stackoverflow error

≯℡__Kan透↙ 提交于 2020-02-25 21:39:08
问题 i am making a length converter which uses TextWatcher. the shortened code is v1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { val1=Double.parseDouble(v1.getText().toString()); val2=InchToCm(val1); val3=InchToMl(val1); val4=InchToKm(val1); val5=InchToM(val1); val6=InchToY(val1); val7=InchToFt(val1); val8=InchToLg(val1)

Multiline `ReplacementSpan` drawing issue

冷暖自知 提交于 2020-02-24 14:40:05
问题 My custom replacement span works as long as text is not too long but as soon as text is longer than one line, span drawing completely breaks apart. My understanding is that draw() gets called twice in this case causing span to draw twice. There is no way to differentiate that second draw call from first one, giving you control over what to draw and where. start and end become useless as they report wrong values. Is ReplacementSpan supposed to even work for multiline text? I would appreciate

EditText input filter causing repeating letters

家住魔仙堡 提交于 2020-02-23 11:34:10
问题 I have been limiting the input to my edittext like this; InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { String output = ""; for (int i = start; i < end; i++) { if (source.charAt(i)!='~'&&source.charAt(i)!='/') { output += source.charAt(i); } } return output; } }; But anyone who has used this method will know that it causes repeating characters when it is mixed with auto correct and the