android-edittext

When the soft keyboard appears, it makes my EditText field lose focus

梦想与她 提交于 2019-11-28 03:03:58
I've got a few EditText fields in a ListView. When I tap on one of the EditText fields, the keyboard slides into view (as it should), but the EditText field I tapped loses focus. I've tried using various InputMethodManager methods to make the keyboard start out in view (in order to get around the problem rather than truly solve it), but that didn't work - the keyboard was not in view when the Activity appeared. The EditText's type is number , and when the keyboard is sliding in, it is a number keyboard, but when it finishes sliding and the EditText loses focus, it changes to the alphabetical

android format edittext to display spaces after every 4 characters

此生再无相见时 提交于 2019-11-28 02:51:11
问题 Android - I want to get a number input from the user into an EditText - it needs to be separated by spaces - every 4 characters. Example: 123456781234 -> 1234 5678 1234 This is only for visual purpose. However i need the string without spaces for further usage. What is the easiest way I can do this? 回答1: You need to use TextWatcher to achieve visual purpose spaces. And use any simply split string by space logic to join it back or loop through the entire string per character wise and eliminate

Cannot resolve symbol showsoftinput

妖精的绣舞 提交于 2019-11-28 02:18:43
I'm trying to force the numeric keypad to show when my activity and EditText load. It seems there's a pretty straightforward answer given here and elsewhere: you say EditText yourEditText= (EditText) findViewById(R.id.yourEditText); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); Fine then. So I do this and I include the imports: import android.content.Context; import android.os.Bundle; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; But when we

Keyboard overlapping EditText on click

戏子无情 提交于 2019-11-28 01:49:13
In my fragment I have an editText inside a scrollview and when I click on that I set it to open like this: getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); It works fine from the first time it opens, but when I close the keyboard and open it again, it overlaps the editText, how can I set the editText to always open in SOFT_INPUT_ADJUST_PAN mode? the XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas

How to highlight Multiple words in EditText?

ぃ、小莉子 提交于 2019-11-28 01:35:58
Currently I'm developing Spelling & Grammar checking app. It has EditText where user can input text & one button called "Check Text " upon click on button app will call LanguageTool API to check text & returns JSON response with result . Here is screenshot of app : Here is code which I have tried so far for highlighting multiple words but this code only highlights last word from array which I have created: for (int i = 0; i < errorStrings.size(); i++) { // Here textToCheck is EditText & errorStrings is ArrayList of type WrongString class which i have created to hold Error string , offset &

NullPointerException on findViewById() in android

人盡茶涼 提交于 2019-11-28 01:11:35
In the following code i get a NullPointerException on lines 9/10 with findViewById(). In my main class I just instantiated an object from this class, to use .getFrom() public class UserInteraction extends Activity { EditText etFrom; int from; EditText etTill; int till; public UserInteraction(){ etFrom = (EditText)findViewById(R.id.et_from); etTill = (EditText)findViewById(R.id.et_till); } public int getFrom() { String s = etFrom.getText().toString(); int i = Integer.parseInt(s); return i; } public int getTill() { String s = etTill.getText().toString(); int i = Integer.parseInt(s); return i; }

How to change color of EditText handles?

冷暖自知 提交于 2019-11-28 01:05:46
Where does the green color comes from? I've tried changing the accentColor attribute, which works in other parts of the app, but not here. Screenshot from app in Lollipop. How can I change the colors of: the text handle drawables? how to tint them? the select-all-background color? And maybe some tips for the future... How did you find out? I've been coming across all these confusing color/styling problems. Is there some kind of list somewhere that tells me, which default color or attribute that I need to overwrite for a certain component? Rajen Raiyarela For changing the handle color you can

Android - Adjust screen when keyboard pops up?

五迷三道 提交于 2019-11-28 00:37:00
问题 I want to be able to adjust my UI screen on Android when the soft keyboard pops up. So at the minute I have something similiar to the first picture below where I have and EditText at the bottom of the screen and when a user taps the EditText I want the same as what happens in the second picture. That is that the EditText gets moved up and appears to "sit" on top of the soft keyboard, when the soft keyboard dissapears it should then return to its prior state. Can anyone let me know the best

How to disable auto-capitalization of an EditText

天大地大妈咪最大 提交于 2019-11-28 00:14:28
问题 This will have a really simple answer, but I can't seem to find what it is. I want to disable the auto-capitalization of an EditText so that, by default, the first letter entered with not be automatically capitalized. I still want to allow capitalization, but only if the user manually does so. I've tried android:capitalize="none" on my EditText, and I've tried android:inputType="text" but both still auto-capitalize the first letter. I don't want to use a TextWatcher because on the soft

Focus issue with multiple EditTexts

烂漫一生 提交于 2019-11-27 23:33:25
I have an activity with two EditText s. I am calling the requestFocus on the second EditText field since by default the focus goes to the first one. The focus appears to be in the second field (the second one gets the highlighted border), but if we try to enter any characters using the hardware keyboard the text appears in the first EditText control. Any ideas why it would be happening? It's hard to tell whether this was your problem, but it's not unlikely. TL;DR: Never call focus-changing methods like requestFocus() from inside a onFocusChanged() call. The issue lies in ViewGroup