4

I have a standard straight forward EditText, I want to show the dictionary suggestions on top of this EditText so I did this in the XML:

<EditText
 android:id="@+id/messaging_messageEdit"
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_gravity="center"
 android:layout_margin="10dp"
 android:layout_weight="85"
 android:background="@drawable/clanz_edit_text_holo_dark"
 android:ems="10"
 android:hint="Type your message here..."
 android:singleLine="true"
 android:inputType="textAutoComplete"
 android:textColor="#dedede" >
</EditText>

I thought that the inputType parameter would take care of the auto dictionary view. On my phone (Nexus Android 5.1) the dictionary view appears but is blank. On a Genymotion emulator (Android 4.1.1) it does not display at all.

What am I missing?

Tim Kranen
  • 4,202
  • 4
  • 26
  • 49

3 Answers3

5

This can be one solutions if you are looking for AutoComplete TextView.

<AutoCompleteTextView
                    android:id="@+id/from_station"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:hint="@string/enter_start"
                    android:imeOptions="actionNext"
                    android:inputType="textNoSuggestions"
                    android:textColorHint="@color/transparent_black" />

You can also set threshold value using paramters. Need to set adapter values at runtime.

strike
  • 1,031
  • 8
  • 24
  • 2
    No, I am not looking for a custom AutoCompleteTextView, I am trying to implement the STANDARD android dictionary suggestions. – Tim Kranen May 26 '15 at 07:45
  • @Tim Kranen this answer is correct you should have need must AutoCompleteTextView without this you can not use Edittext to make autosuggest or auto complete – Amitsharma May 26 '15 at 08:04
  • @amitsharma I have already tried replacing the EditText with an AutoCompleteTextView but the result is the same, the suggestions are empty. – Tim Kranen May 26 '15 at 08:10
  • why are you replacing AutoCompleteTextView at the place of edittext you have need both tpo do i m shareing you a link see this – Amitsharma May 26 '15 at 08:13
  • http://androidexample.com/Show_Phone_Contacts_In_AutoComplete_Suggestions_-_Android_Example/index.php?view=article_discription&aid=106&aaid=128 – Amitsharma May 26 '15 at 08:16
  • @amitsharma Thanks for the help but this is not the problem. I know how an AutoCompleteTextView works, I want to turn on the dictionary for my edit text. The standard Android dictionary. – Tim Kranen May 26 '15 at 08:28
1

If I understand correctly you want the keyboard to have auto correction right?

According to the Android developers website:

Can be combined with text and its variations to specify that this field will be doing its own auto-completion and talking with the input method appropriately. Corresponds to TYPE_TEXT_FLAG_AUTO_COMPLETE.

This is not what you're looking for. You are probably looking for textAutoCorrect which is this according to the Android developers website:

Can be combined with text and its variations to request auto-correction of text being input. Corresponds to TYPE_TEXT_FLAG_AUTO_CORRECT.

I've made a lot of apps and never used one of those though. It just auto corrects if you have a normal EditText.

Kevin van Mierlo
  • 9,554
  • 5
  • 44
  • 76
  • Yes, this comes more down to the issue. However I tried both solutions and still auto correction doesn't work. The suggestions just stay empty. – Tim Kranen May 26 '15 at 08:53
  • Hmm that's really weird. I just created a new project and put your `EditText` in the layout. I just changed inputType to `textAutoCorrect` and I don't have the drawable, so I left that out as well. For me it's working right now. I use the google keyboard which you can download in the Play Store. – Kevin van Mierlo May 26 '15 at 09:00
  • Let me try that out again then, but it'll take a while so I'll get back to you! Thanks! – Tim Kranen May 26 '15 at 09:34
  • I am going to test this answer this afternoon, I couldn't get back at it before. – Tim Kranen May 30 '15 at 10:04
  • This solution did not work. But in order to prevent @strike from getting the bounty, I'll award it to this since this is answering the question. strike did not answer the my question. – Tim Kranen Jun 02 '15 at 09:59
  • @TimKranen Thanks! I still want to help, maybe you can share your project with me and then I can take a look. Cause this solution is working on my phone and emulator. – Kevin van Mierlo Jun 02 '15 at 10:02
  • I am going to test it out on multiple devices later on, I'll update you if these do work. It might be a device related issue. Thanks a bunch for your help!! – Tim Kranen Jun 03 '15 at 07:24
  • @TimKranen No problem, hope you can fix the issue! – Kevin van Mierlo Jun 03 '15 at 08:08
0

I had the same problem not getting keyboard suggestions on some of my EditText views. Please pay attention there is a difference between autoComplete text views and getting keyboard suggestions while typing! They happen in two different places, first one inside the AutoCompleteTextView the other one on top of your keyboard while typing.. (for example you type te => it suggests "tea teaspoon teapot" to make your life easier.) To achieve that I had to turn off the input types that I was setting programmatically and when you do so, the default behavior is back and that means getting keyboard word suggestions:

//  etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

I tried the following but I still did not get a keyboard suggestions:

etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

at the end I commented all the above and it worked just fine!

here I also found that someone else had the reverse problem meaning they wanted to disable this functionality and they suggested to use the code that I had commented! read here

Araz
  • 151
  • 2
  • 11