Мне нужно реализовать AutoCompeleteTextView, как приложение по умолчанию для обмена сообщениями. Я уже реализовал его, как показано на первом изображении. Теперь я хочу точно так, как указано во втором изображении.AutoCompeleteTextView как приложение по умолчанию для Android по умолчанию
Этот фрагмент кода я использую:
Cursor cursor = this.getContentResolver().query(Phone.CONTENT_URI,
new String[] { Phone.DISPLAY_NAME, Phone.NUMBER }, null, null,
Phone.DISPLAY_NAME + " ASC");
startManagingCursor(cursor);
cursor.moveToFirst();
int i = 0;
do {
HashMap<String, String> map = new HashMap<String, String>();
map.put("No", cursor.getString(cursor.getColumnIndex(Phone.NUMBER))
.replace("-", ""));
map.put("Name",
cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME)));
list.add(map);
i++;
} while (cursor.moveToNext());
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.autocomplete, new String[] { "Name", "No" },
new int[] { R.id.name, R.id.number });
txt_mobile_no.setAdapter(adapter);
txt_mobile_no
.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
и файл макета, как показано ниже: autocomplete.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="40dip"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/name"
android:textSize="16dip"
android:layout_weight="1"
android:textColor="#000000"
android:paddingLeft="6dip"
android:paddingTop="10dip"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/number"
android:textSize="16dip"
android:layout_weight="1"
android:textColor="#000000" android:paddingTop="10dip"/>
</LinearLayout>
Теперь, пожалуйста, может кто-нибудь предложить я лучший способ реализовать эту функцию.
Посмотрите здесь: http://thinkandroid.wordpress.com/2010/02/08/writing-your-own-autocompletetextview /. – Edi