Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show suggestions on a "multiline" MultiAutoCompleteTextView?

Tags:

android

Can someone tell me how can I show suggestions on a "Multiline" MultiAutoCompleteTextView. I went to the API reference Here.

I tried that example and the Autocomplete worked just fine except when i go to the next line I do not see the suggestions any more.

I have an xml that definees my MultiAutoCompleteTextView like so:

<?xml version="1.0" encoding="utf-8"?>
<MultiAutoCompleteTextView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/html"
        android:focusable="true"
        android:gravity="top"
        android:background="@null"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingBottom="5dp"
        android:singleLine="false"
        android:completionThreshold="1"
        android:textSize="14dp"
        android:scrollHorizontally="true"
        android:focusableInTouchMode="true" />

My code that does the suggestions is like so: (Got it from the reference)

   MultiAutoCompleteTextView editor = (MultiAutoCompleteTextView) LayoutInflater.from(getApplicationContext()).inflate(R.layout.editor, null);

   ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
   editor.setAdapter(adapter);
   editor.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

Since I set the singleLine to false on my MultiAutoCompleteTextView xml. The suggestions do not show when I press enter to go to the next line.

Can anyone help me on this. Is there a way i can override the suggestions panel to my liking? Also is there a way to position the panel?

like image 724
centricomen Avatar asked Nov 03 '22 16:11

centricomen


1 Answers

android:inputType="textMultiLine"

"Normal text keyboard that allow users to input long strings of text that include line breaks (carriage returns)."

http://developer.android.com/guide/topics/ui/controls/text.html

like image 177
Stéphane Avatar answered Nov 14 '22 15:11

Stéphane