android autocompletetextview hint results hidden under keyboard - android

I have 3 autocompletetextview's in which i set its adapter to be an ArrayAdapter<String> with a very simple textview layout.
The autocompletextview hint results are showing, but are under the onscreen keyboard(i can see part of it). how can i make the results show above the autocompletetextview rather than below?
airline = (AutoCompleteTextView)findViewById(R.id.airline);
airline.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, AIRLINES_AUTOCOMPLETE_ARRAY));
departLocation = (AutoCompleteTextView)findViewById(R.id.departLocation);
departLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
arriveLocation = (AutoCompleteTextView)findViewById(R.id.arriveLocation);
arriveLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));

Simply limit the drop-down height.
android:dropDownHeight="200dp"
Then results don't hide by the soft keyboard.
Or else do this
The theory says that android:windowSoftInputMode="adjustPan|adjustResize" should do this but for some reason, it doesn't, so you have to do the same programmatically:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Use a ScrollView for the layout where your Autocomplete resides and Voila!

Does your Activity adjustResize?
android:windowSoftInputMode="adjustPan|adjustResize"
reference: Move layouts up when soft keyboard is shown?

you should look here : Creating an input method
Composing text before committing
If your IME does text prediction or requires multiple steps to compose a glyph or word, you can show the progress in the text field until the user commits the word, and then you can replace the partial composition with the completed text. You may give special treatment to the text by adding a "span" to it when you pass it to InputConnection#setComposingText().
this way, suggestions will apears on soft keyboard prediction like auto-correction. An other way of doing it will be a fullScreen IME... with ExctractEditText : See this link...
This is what i usualy have seen in other apps... i don't think the autocompletetextview can be inverted and appears on top of the view, but what's strange is that it usually shows on top of the keyboard not bellow...

I had the same problem with this a little while ago. You Can try manipulating the z-index of the elements that are being hidden to force it to the top which would be your views in this case. Hope it works for you !

another quick solution is by using the attribute "android:dropDownAnchor"
to anchor the dropdown to some other view on top of screen

Add an attribute in your AndroidManifest.xml
android:windowSoftInputMode="adjustPan|adjustResize"
Which will auto resize and adjust the soft keyboard.

Use
android:windowSoftInputMode="adjustPan|adjustResize"

If none of the above solutions worked. try this
android:dropDownHeight="match_parent"
If we didn't mention the dropdown height, it would be considered wrap_content. Therefore the item will show behind the soft keyboard.

Take the autocomplete textviews in respective layouts then you see they opens their values in it only (ABOVE), set autocomplete texview (bottom) of each layouts, as per your question you required three child layouts.
it is really working

Related

Android Scrollview doesn't scroll when keyboard appears onClick of EditText

I've been through n number of solutions for this problem and tried them all but nothing helped.
I have an EditText and onClick of it, a custom keyboard appears but the EditText doesn't comes up above the keyboard.
I have tried putting:
android:windowSoftInputMode="stateAlwaysHidden|adjustPan|adjustResize"
in my Manifest file.
I read somewhere that its a bug and it does not work in FULLSCREEN mode so I removed fullscreen mode from my manifest. Again didn't work.
Please help scrolling my EditText up :D
P.S: Please don't answer for android's default keyboard. I am using my own custom keyboard.
In scrollView use the following code:
in XML:
android:fillViewport="true"
OR
in Java:
setFillViewport(true);
You have to use a translate animation, to move the Edit-text or the entire view above the keyboard along with the Y-axis.
As you are using a custom keyboard,no other way seems to be possible.

How to enter special characters in an EditText in Android?

Is there any way to input special characters (which are not present in the default soft keyboard ,eg. theta) in an Android EditText?
Thanks..
Well as per your need, I would like to suggest to create a custom keyboard because the stock keyboard which comes with the device may not have the special characters you need.
You can refer the following tutorial to create a custom keyboard
http://www.fampennings.nl/maarten/android/09keyboard/index.htm
or you can see this search result which may serve your purpose,
https://github.com/search?q=android+custom+keyboard&ref=cmdform
And from below site you can get the list of Unicode characters which Android supports,
http://en.wikipedia.org/wiki/List_of_Unicode_characters
http://unicode-table.com/en/#0026
Note: Writing the whole code to create a custom keyboard is beyond the scope of this answer, so I mentioned the reference link.
What you are going to do is to create a custom keyboard. First thing you want is to hide the default keyboard when an EditText is focused:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Now, you must create a custom layout (RelativeLayout or Multiple LinearLayouts this is your desire), create and set text to the buttons that you want to show. Make this keyboard view setVisibility(View.INVISIBLE) or setVisibility(View.GONE), and whenever your EditText is focused, make it setVisibility(View.VISIBLE).
After keyboard is visible, programming the rest is up to you it is practically easy.
If you also need a guide, here is an example.

Keyboard issues arising on orientation change

In my app I am using various edit text and text view and list view.
Now my problem is my keyboard appears again on orientation change. Ideally when user minimize the keyboard, it should be in minimized state when device is tilted. But it reappears. How do we handle this situation.
My other problem is one of my edit text is some what at the end of screen. When keyboard appears, it hides the edit text. so user is not able to see what he is typing. What is the ideal way to handle this.
thanks.
Solution to all problem is this line android:windowSoftInputMode="stateUnchanged|adjustResize"
"stateUnchanged" will make the state of keyboard same as it was in earlier state. Either hidden or visible.
"adjustResize" will make your edit text visible.
Hope this helps.!!!
Edit
This need to be added in android manifest file.
I had this same problem. To keep the keyboard from re-appearing on rotation when you have TextViews, you must do 2 things-
Make sure the TextView doesn't have the focus. Even after hiding the keyboard, a TextView can still be focused. Try calling
textView.clearFocus()
and you should be able to see the difference in the TextView.
Make sure there is another view before it (like a parent LinearLayout, or even just a LinearLayout with 0 width and 0 height) which has these properties-
android:focusable="true"
android:focusableInTouchMode="true"
Try adding this code in your Activities properties in the manifest
android:windowSoftInputMode="stateHidden|adjustPan"
Like
<activity
android:name=".MyActivity"
android:windowSoftInputMode="stateHidden|adjustPan" >
This should take care of both your problems
For the Second Question :
You can set your layout to ScrollView to avoid hiding of edittext on Keyboard appears.
Put your entire layout in a ScrollView.
I found the following documentation to be helpful in understanding the various flags associated with the soft keyboard:
https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

iphone-style text edit on android

I'm trying to make iPhone-style EditText element on android.
The one that will have an additional clear button appear on the right after text input.
Adding a new button is not a problem, but I'm a bit stuck with another thing.
A button occupies some space on the right part of EditText, and now characters display beneath the button. How to change maximum shown length of input for EditText?
I want EditText width to be N pixels, and editable area to be N-M pixels.
EditText.setWidth changes width for whole edit box.
EditText.setEllipsize should be the proper solution, but docs are empty, and as I see it truncates text based on some String value.
Applying a LengthFilter cut's the input length to number of characters.
Thanks in advance.
I suspect that android:drawableRight will save you a lot of pain.
Seems I've found a solution.
EditText.setPadding(l,t,r,b) seems to work fine, applying only for editable area
Try this : http://mytechead.wordpress.com/2012/02/07/create-ios-like-cleartextbutton-in-android/
This is a very old question, but thought I'd add my two cents for kicks. I'd probably use a 9 patch for this and set the content area to stop the text before it hits the button area.
This would require creating a custom view so that you can add a button in the desired position using relative layout so that it can be clicked to clear the edittext.
Alternatively you can use the compound drawables, but you would need to implement something like this
Handling click events on a drawable within an EditText so that you can handle the click events. Keep in mind that I doubt the button states (eg the down state) will work using this method.

Selection list cut off in AutoCompleteTextView in Dialog

I have a dialog window that covers 1/3 of the entire screen height and is displayed on top of my activity. The dialog holds two AutoCompleteTextView fields.
The problem I'm facing is that when the user starts typing something into the AutoCompleteTextView, the list with all suggestions only shows up to the bottom end of the dialog, but doesn't go beyond that even the list is longer. It looks like it's cut off. (screenshot left)
Only after I long-press an item from the suggestion list, the list will be shown in full length. (screenshot right)
Screenhot is at: http://img704.imageshack.us/i/dialogdropdown.png/
screenshot http://img704.imageshack.us/img704/1893/dialogdropdown.png
How to fix this behaviour so that the list shows in full length right from the beginning, when the user starts typing something?
Code-wise there's nothing special, all I do is:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), R.layout.nav_route_autocomplete_row, locStrings);
AutoCompleteTextView txtStartPos = (AutoCompleteTextView) findViewById(R.id.txtStartPos);
txtStartPos.setAdapter(adapter);
...
One workaround idea is to somehow dispatch a motion event to simulate a touch (but then not selecting though) one of the list items. Any concrete idea in code for a solution, anybody?
Right now I'm assuming it's a bug, which I already filed here: http://code.google.com/p/android/issues/detail?id=9917
But if anybody knows a solution to this, I'd greatly appreciate it and would be glad to trade it for some bounty points.
Edit:
One workaround that came to my mind is now to extend the dialog to the very bottom of the screen but leave the background transparent, so it looks the same as now, but actually has a height that wouldn't cut off the list. I will give that a try...
Not long ago i faced this problem. I had small dialog with AutoCompleteTextView, which had more than 10 items in Drop Down list. This list was cutted. My solution was:
Place some empty View in my Dialog layout file with parameters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--
Some Views placed here
-->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
</LinearLayout>
It made my little dialog like a full screen dialog, but actualy that "tail" wasn't showed, and my DropDown wasn't cutted at all, cause it had enough place to show list items from DropDown.
if (yourlist.size() > 5) {
yourtextview.setDropDownHeight(562);
} else {
yourtextview.setDropDownHeight(anytextview.getHeight() * yourlist.size());
}
//Workaround -> Write this condition under on click and on focus change of your autocomplete text view
Just a shot in the dark, but have you tried setting android:clipChildren to false on the view for the dialog atop your Activity?
I have successfully achieved this, but it isn't pretty.
I ended up overriding my SimpleCursorAdapter.newView() method, walking up the ViewParent hierarchy until I reached the root View, and then modifying its WindowManager.LayoutParams by ORing in the FLAG_LAYOUT_NO_LIMITS flag.
This needs to be redone every time the drop down is displayed.
As seen here: Scrolling drop-down-menu over the keyboard in autocompletetextview
You can use the property android:dropDownHeight of the AutoCompleteTextView to force it to be of a certain height. This is not really solving the problem, but is the best I could find.
Note: This problem only happens when using AutoCompleteTextView inside a Dialog. When it is used on the layout of an activity or a fragment it just works fine.
This issue is present all the way from Gingerbread to Jelly Bean.

Categories

Resources