Hello All,
I am working on a Free SMS sending application for a website and for this I need to implement the MultiAutoCompeleteTextView like Default Message Application as shown in screen shot below!
I had already implemented this feature in my application but it is slightly different and look like:
The Following code snippet i am using:
private void loadContactsList()
{
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());
}
and the layout file is as below:
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 as in first screen shot.
I am very new to Android so please help me.
Thank You all........