I tried quite a number of suggestions while I sifted through the Stackoverflow forum but one of them worked without hassles.

It is short and simple: simulate a tap on the EditText component.

You can do this by doing:

That’s all.

Of course, when doing it programmatically, the first thing we do is call requestFocus() but there are certain cases where the soft keyboard will not show up. The code above will ensure that the soft keyboard will always show when it is called.

I bet you get confused why the ListView object does not capture click events at times. Ever thought that maybe the components within each ListView entry contain components that accept input events?

Take for example EditText or a Spinner? If this was a regular TextView, then there will definitely be no problem when it comes to capturing click events in the OnItemClickListener or OnItemLongClickListener().

What you can do to fix this is to set your EditText component to disable events so these such events will be relegated to the ListView.

You can do this by setting android:focusable=”false” and android:focusableInTouchMode=”false” in the XML layout file. Try it and check it out.

You will see that by setting these attributes to false in your EditText, your ListView object can then capture click events.

Forcing an EditText to accept a number value from a certain range entails the use of filters using the InputFilter class. I created a custom made class that lets you set an EditText to accept only values between a minimum and maximum value.

Here is the class.

To use the class, do it like this which sets an EditText to accept any number between 1 and 100.

There! Now you should be able to have your EditText accept only your desired values. Just be sure you set your EditText widget to accept only numbers.

Related Posts Plugin for WordPress, Blogger...