android-edittext

Android listview edittext filter space button?

…衆ロ難τιáo~ 提交于 2019-11-29 17:20:01
I have created a filter listview where user will enter input via edittext and results are filtered in the listview. The code is running good but when ever i press Space button, results in the list view disappears. how can i add space in search input without dismissing the listview contents ?? Here is my current code : myListview.setTextFilterEnabled(true); edNearBy.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } public void beforeTextChanged(CharSequence s, int start, int count, int

Edit Text key listener

旧街凉风 提交于 2019-11-29 17:17:32
问题 I have an edittext and a button in my layout and in my code I'm setting keyListener of the edittext as null editText.setKeyListener(null); so that I cannot type into my edittext . Now on my button click I should be able to type into my ediitext . How can I do that. It's a simple problem, but I'm not able to find any solution. Any help would be much appreciated. 回答1: I'm probably late now but, this is the way I do it: public class MyActivity extends Activity { private KeyListener listener;

EditText does not trigger changes when back is pressed

半腔热情 提交于 2019-11-29 17:12:53
In an application with shopping cart, I give the option to change the amount of items via an EditText which allows only numerical input. Everything works fine, except when the user changes the field and then presses the back key to hide the soft keyboard. In this case, the field shows the changed value, but I don't know how I can detect this change and react on it. Waiting for a switch to another activity is not an option. When the user confirms with "done" button, I can handle this with a "OnEditorActionListener". But what about the back key? update: As it turned out, neither onKeyDown /

Android EditText alternative

纵饮孤独 提交于 2019-11-29 16:45:02
问题 Currently, Android's EditText is extremely slow when dealing with a huge amount of lines of text (10000+). It appears like this slowdown is partially due to the fact that EditText supports spans, and primarily due to the fact that EditText is calculating the width of each line, which is very expensive. Are there any faster alternatives to EditText, or a way to optimize it to make it usable? EDIT: Method traces are as follows: android.text.StaticLayout.generate: 99.1% CPU time inclusive, 8.8%

Android: Different colours for different characters in EditText

自闭症网瘾萝莉.ら 提交于 2019-11-29 16:42:10
Thank you in advance for any responses. I am trying to have an EditText in my Android application which has different colours for different characters which are typed in. For e.g. Alphabet "A" should always be blue, alphabet "b" should always be green... so on. So far, I have no been able to find a solution for it. Please be kind enough to guide me in the right direction. As was pointed out, you can apply Spannables to the text as it is entered. Something like this: colorEdit.addTextChangedListener(new TextWatcher() { String lastText = null; @Override public void onTextChanged(CharSequence s,

How to right-align text in an Android TextView or EditText?

余生长醉 提交于 2019-11-29 16:34:10
问题 I have an EditText in my application. I want to align the text in it to the right instead of the default left. I tried adding android:layout_gravity="right" but this doesn't seem to work. any other suggestions please? 回答1: You should use android:gravity="right" . layout_gravity is for the view (EditText) alignment against the container. 回答2: You may use android:layout_alignParentRight="true" to align the EditText's right edge to its parent's right edge. Also, if you really want to use the

Android - Checking if editText is >3 before and after user input

会有一股神秘感。 提交于 2019-11-29 16:10:34
I have some code where I need a "Create Account" button to be disabled if an editText field has less than 3 char in it. If the User enters 3 chars, then the button should enable itself so that it can be used. I have constructed the if else statement that disables the button if there are less than 3 char in the editText field, BUT on input, when the user inserts 3 char, it does not re-evaluate to see if the statement is true so the button of course stays disabled. Once the user enters 3 char into the edit text field, the button should enable itself. Button buttonGenerate = (Button) findViewById

Issue with empty EditText

こ雲淡風輕ζ 提交于 2019-11-29 15:53:22
I have an Activity with an EditText, Button and TextView. If I write some numbers and click the button, the TextView shows the result of the calculation. If the EditText is empty (i.e. there are no numbers entered) and I click the Button I have the a dialog saying: "The application has stopped unexpectedly. Please try again". Please help me. I want to show a window with some comments (for example "Insert numbers"), if the user does not write any numbers. How should I program the EditText field? How to solve this? Thanks a lot This is my onClick method: public void onClick(View v) { EditText

Highlight Textview Using EditText

做~自己de王妃 提交于 2019-11-29 15:52:09
问题 Im currently making a search engine like application for android and i want to highlight the searched word from edittext to textview... this is that i got so far and it only highlights the first word in the textview TV.setText("Hello World", TextView.BufferType.SPANNABLE); Spannable WordtoSpan = (Spannable) TV.getText(); WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), 0, notes.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TV.setText(WordtoSpan); 回答1: I think you want to highlight a

Child class of EditText looks different than normal EditText on Android 4

帅比萌擦擦* 提交于 2019-11-29 15:32:32
问题 This is a 'bug' that I discovered while working on a real app, but I created a blank project to reproduce it. I have the following layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:id="@+id/root" android:orientation="vertical" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin