Hi All,

I'm using AutoCompleteTextView with SimpleCursorAdapter. It works
properly except one issue: I can't get regular list dropdown view.
When performing filtering the lines are narrow. I've tested API Demos
AutoCompelte1 example and got the "normal" dropdown view when using
ArrayAdapter<String>.
Is there any standard way  to show "normal" dropdown view? Please
advise what is wrong or what I've missed there.

Thans a lot,
Evgeny

The source code is following:

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

       MyAdapter adapter = new MyAdapter(this,
                                android.R.layout.simple_spinner_item, null,
                                new String[] {"name"},
                                new int[] {android.R.id.text1});
        AutoCompleteTextView autoCompleteCountry =
(AutoCompleteTextView)findViewById(R.id.txtCountry);
        autoCompleteCountry.setAdapter(_adapter);
        //
autoCompleteCountry.setDropDownHeight(LayoutParams.FILL_PARENT);
        //
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
        adapter.setStringConversionColumn(1);
    }

        private class MyAdapter extends SimpleCursorAdapter
        {
                public MyAdapter(Context context, int layout, Cursor c, String[]
from,int[] to)
                {
                        super(context, layout, c, from, to);
                }

                @Override
        public Cursor runQueryOnBackgroundThread(CharSequence
constraint)
                {
                        if(constraint == null || constraint.length() == 0)
                                return 
super.runQueryOnBackgroundThread(constraint);


                        return myB.rawQuery("select country._id _id, 
country.name_en name
from country where name_en like '" +
constraint.toString().replace("'", "''") + "%'", null);
                }
        }
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

        <ScrollView
                android:id="@+id/ScrollView01"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
                <LinearLayout  android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
                        <TextView
                            android:id="@+id/lblCountry"
                            android:layout_width="fill_parent"
                            android:text="@string/lblCountryFrom"
                            android:layout_height="fill_parent"/>

                        <AutoCompleteTextView
                                android:id="@+id/txtCountry"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">
                        </AutoCompleteTextView>
                </LinearLayout>
</ScrollView>
</LinearLayout>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to