android-edittext

EditText OnKeyListener not working

戏子无情 提交于 2019-11-28 12:06:53
I know this/similar question has been asked before but the solution given is not working for me so I'm asking again. I tried the solution given in that answer but still my OnKeyListener is never being invoked on some devices, especially the ones with stock OS. I need to detect pressing of del key of soft keyboard when when there is no character in editText. Here is my code; EditText et = (EditText) findViewById(R.id.et); et.setOnKeyListener(new EditText.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { Log.d("OnKeyListener", keyCode + " character(code) to

Android: EditText Validation with TextWatcher and .setError()

社会主义新天地 提交于 2019-11-28 11:50:33
i have implemented a simple validation for an TextEdit, using this code: title = (EditText) findViewById(R.id.title); title.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (title.getText().length() < 1) { title.setError( "Title is required" ); } else { title.setError(null); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } }); The funcion

EditText Input type Issue

天涯浪子 提交于 2019-11-28 11:42:42
问题 There is a name EditText in my screen. I want to accept only alphabets means from a-z,A-Z and should not accept numbers, special chars. I'am using inputtype="textPersonName" for that but its notworking, it accepts means showing all numbers, chars etc.. For phone field inputtype="phone" is working it accepting means showing numbers in field` only. Why like that? 回答1: Your best bet is to use an InputFilter to restrict the characters that are permitted in your EditText control. You should be

How to parse a double from EditText to TextView? (Android)

那年仲夏 提交于 2019-11-28 11:28:15
I'm realy beginning to learn Java. When I run this code everything works fine till I leave my EditText boxes in the from empty and hit the run button. Then I get: ERROR/AndroidRuntime(866): FATAL EXCEPTION: main ERROR/AndroidRuntime(866): java.lang.NumberFormatException: ERROR/AndroidRuntime(866): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267) I guess when I try to parse a Double from string it doesn't get any value and creates an error. I was wondering how to avoid this error and give some kind of a value to the variable so it is never empty?

How do I get MultiAutoCompleteTextView tokenizer similar to Facebook app?

左心房为你撑大大i 提交于 2019-11-28 11:11:14
I am creating an application which has a 'To' field just like in Facebook app's "New Message" feature. After selecting an item from the drop down list, I create an imagespan and add it to the MultiAutoCompleteTextView . I have used SpaceTokenizer for this view . The problem is when I click on backspace, the cursor first moves to the empty space (i.e., space Tokenizer ) and then when I click on the backspace again, the whole word gets deleted....I want to delete the whole word on my first click of backspace just like facebook app... Here is my code for SpaceTokenizer multiContentText

EditText: how to enable/disable input?

不打扰是莪最后的温柔 提交于 2019-11-28 11:10:23
I have a 7x6 grid of EditText views. I want all of them disabled when the application starts, ie they should behave like normal TextViews and not to be editable. Then the user taps one cell in the grid, it changes its background and performs something visual. If the user clicks on the cell one more time it should allow editing. I'm struggling with OnClick() and OnFocusChange() listeners, but I can't accomplish such a basic interaction. Playing with setEnabled() and setFocusable() doesn't help. I wonder why even a simple task like this has been made so difficult on Android Raffaele I finally

EditText does not trigger changes when back is pressed

和自甴很熟 提交于 2019-11-28 10:55:41
问题 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

Android: EditText focus jumps to another inside ScrollView

 ̄綄美尐妖づ 提交于 2019-11-28 10:51:24
问题 I have multiple fragments horizontally adjacent using a ViewPager. Each fragment has a ScrollView that contains a table with many EditText views. When I click on a EditText, it gains focus and then loses it to some other EditText in the leftmost fragment. Sometimes the focus switch happens immediately, sometimes while I am typing into a EditText. Usually, the topmost EditText in the leftmost fragment steals focus. I don't see the problem when a EditText in the leftmost fragment is clicked,

Android: EditText hint in single line

走远了吗. 提交于 2019-11-28 10:45:49
For setting the Single Line in EditText we use android:singleLine="true" but I want to set the single line for the Hint Text, it is large and I want to show it in a one line like: http://google.myopenid.stackoverflow.com I am using the following code: <EditText android:id="@+id/editText1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/defaultUrl" android:singleLine="true" /> Note: defaultUrl is dynamic and very long URL. You can use android:ellipsize="end" android:maxLines="1" to show your hint text in single line but you wont be able to see the

Change font for EditText in Android?

大城市里の小女人 提交于 2019-11-28 10:42:34
Is there any way to change the font for a EditText in Android? I want it to match the font's I set for all my textViews. Samir Mangroliya editText.setTypeface(Typeface.SERIF); As like as for TextView. <TextView ... android:typeface="serif" ... /> Edit: Above is the XML Solution1:: Just call these method by passing parent view as argument. private void overrideFonts(final Context context, final View v) { try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } } else if (v