How do I turn edittext on and off? - android

I have an EditText field that has this
android:inputType="time"
I want to enable it with a button press (like change time) and disable it when done with another button press (like Enter). Someone suggested that you can disable an EditText field with
textView02.setInputType(null);
Which works, but I can't figure out how to get it back to having the default method enabled.
The other thing I tried, and it comes close to working is to turn off the field with this
textView02.setInputType(InputType.TYPE_NULL);
And turn it back on with this
textView02.setInputType(InputType.TYPE_DATETIME_VARIATION_TIME);
But I get the full keyboard requiring shifting to symbols to get the :
I thought I could use this
textView02.setInputType(InputType.TYPE_CLASS_DATETIME);
but I get unwanted characters / and - and worse than that it takes a long press on my phone to get the : instead of the /
PS. In a perfect world I would not need the enter function but instead rely on the done key on the pop-up keyboard. But I can live with a dedicated button.
Allen

textView02.setEnabled(false);
And to reenable, pass it true.

Every class extending View has the setEnabled(boolean) method.

Related

How to trigger the horizontal orientation keyboard?

Context:
I have a small EditText field in my Activity, and it needs to be small because there is a lot of another View's on this Activity. But the content most of times are very long, and the user have a bad experience typing long texts into a small field.
Question:
How i can always show the "Horizontal Keyboard" when the user click on the EditText, even if the user are at Vertical Orientation(portrait) ?
Example:
Here is a screenshot of the "Horizontal Keyboard" that i'm talking about:
Important:
Setting the orientation to horizontal, is not really necessary. If this same keyboard shown on the image above can be triggered even if you are using vertical orientation, it would be useful too.
Sorry, I don't have 50 reputation points for commenting. But this link is for a question where OP is trying to disable the full screen keyboard. Perhaps if it's possible to disable, probably you are able to force enable it.
Disabling the fullscreen editing view for soft keyboard input in landscape?
EDIT:
So, searching a little more, I came to the conclusion that you can't force the keyboard to enter in fullscreen mode. Unless you make a keyboard app of your own that works only in fullscreen. But still would need the user to activate it on the settings menu.
Anyway, I found this solution by a user: force fullscreen on edittext in android, the answer suggests creating an Activity just for writing (an Activity with only an EditText as it's layout). And calling this Activity with the startActivityForResult method. Thus returning the text entered by the user and placing it on the respective EditText (or whatever widget you are going to use for the text).
Again, hope it helps.

Android Virtual Keyboard buttons disabled inappropriately (Kindle Fire)

I have a user reporting an error with my app. I have several EditText fields in my layout. I only want the user to be able to enter signed decimal numbers. However, I don't have the layout declare them to be number|numberSigned|numberDecimal because I have a custom TextWatcher attached to these fields which handles the input and makes sure it is correct. I do this because I want the minus key to act as a toggle.
Let's say, the field has "300" in it. If the user taps minus, my custom TextWatcher intercepts it and turns it into "-300" instead of "300-". If they tap minus again, it'll remove the existing minus and change it to "300".
This works just fine for just about everybody, but it doesn't work on the Kindle Fire. The decimal point and the minus key on the virtual keyboard are disabled, so they don't even have the option of tapping those keys and letting the custom text watcher do its work.
If I do declare the fields to be number|numberSigned|numberDecimal, then the fields won't let the user tap the minus key unless the cursor is in the left most position (i.e. before the 3 in 300).
How can I tell the Kindle Fire to make sure the decimal point and minus keys need to be active, but at the same time not restrict the user's allowed input before it reaches my custom TextWatcher... you know, like the way EVERY other Android device has been working for me? :)
The answer from #zapl:
theEditText.setRawInputType(Configuration.KEYBOARD_12KEY)
worked! Go find some other good answer of his and upvote him so that he can get proper credit for this answer. ;)

How to use OnKeyboardActionListener?

Simply say, is there any example about 'OnKeyboardActionListener'?
I want to call my method, whenever user type any character on keyboard.
OnKeyListener or OnKeyDown is not called when the word is composing. <- it's a problem.
So, I'm trying to use 'OnKeyboardActionListener' to solve the problem above.
Simply say, is there any example about
'OnKeyboardActionListener'?
This interface is used in the creation of input method editors ("soft keyboards"). The SoftKeyboard sample that shipped with your SDK uses this interface.
I want to call my method, whenever
user type any character on keyboard.
If this is your own keyboard, follow the SoftKeyboard example.
OnKeyboardActionListener is for implementing software keyboards.
OnKeyListener and OnKeyDown do not get called, as you have discovered, when using a software keyboard. They only get called when using a hardware keyboard, which many Android devices don't even have.
I assume what you are trying to do is capture key events as they are occurring in an EditText area. Your best bet in this case, in order to handle both software keyboard input and hardware keyboard input, is to register a TextWatcher via the addTextChangedListener() method.
Note that on phones with Android 2.1 and later, such as the Nexus One, people have the option of using speech recognition to input text into your EditText instead of typing the text. When they do that you may get full words, or even full sentences, entered all at once. So you need to check the entire contents of the EditText field when there is a change to the contents.

how to hook key event

I'd like to limit the text length of EditText widget,
And if user type more charactes than the limited length,
I want to show a kind of warning popup, however I can't show popup.
The problem is that we can't show popup while typing,
Probably, many people think a way of utilizing OnKeyListener or OnKeyDown.
But, when the word is composing, nothing come into OnKeyListener or OnKeyDown,
So, we can't show popup when we want to.
Is there anyone who have smart idea to solve this problem?
You should be able to remove focus from the widget, and show your message.
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);
OnKeyboardActionListener is for implementing software keyboards.
OnKeyListener and OnKeyDown do not get called, as you have discovered, when using a software keyboard. They only get called when using a hardware keyboard, which many Android devices don't even have.
I assume what you are trying to do is capture key events as they are occurring in an EditText area. Your best bet in this case, in order to handle both software keyboard input and hardware keyboard input, is to register a TextWatcher via the addTextChangedListener() method.
Note that on phones with Android 2.1 and later, such as the Nexus One, people have the option of using speech recognition to input text into your EditText instead of typing the text. When they do that you may get full words, or even full sentences, entered all at once. So you need to check the entire contents of the EditText field when there is a change to the contents.

Android Virtual Keyboard KeyListener for getting Virtual Keyboard key presses

I want that on each key press I require to change the Counter some what similar to Tweeter Thing but the issue is that OnEditorActionListener only calls for the change while the user presses Enter or Done key, Please Can I Find a Resolution for this
You could use an OnKeyListener if you do really want to catch keystrokes.
However, if what you're really interested in is knowing when the text in an EditText View has changed you might find it easier to use a TextWatcher. You would put your code which updates something based on the context of the EditText in the afterTextChanged() method.

Categories

Resources