本文介绍了AutoCompeleteTextView像Android的默认的邮件应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要实现AutoCompeleteTextView喜欢默认的邮件应用程序。我已经实现了它作为第一个图像给出。现在,我想正是因为在第二图像给出。
I need to implement the AutoCompeleteTextView like default Messaging application. I have already implemented it as given in first image. Now I want exactly as given in second image.
我用下面的code片断:
The Following code snippet I am using:
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>
现在请可能有人建议我一个更好的方式来实现该功能。
Now please could anybody suggest me a better way to implement the feature.
推荐答案
最后,我已经得到了究竟我一直在寻找。
Finally I have got what exactly I was looking for.
链接是在这里:
定制AutoCompleteTextView为Android
这篇关于AutoCompeleteTextView像Android的默认的邮件应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!