main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Multi Auto Complete TextView"
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:textColor="#336633"
android:textStyle="bold"
android:textSize="20sp"/>
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="MultiAutoCompleteTextView"
android:layout_gravity="center"
android:layout_marginTop="40dp" >
<requestFocus />
</MultiAutoCompleteTextView>
</LinearLayout>
MultiAutoCompleteTextViewActivity.java
package com.anju.tiwari.multiautocompletetextview;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.MultiAutoCompleteTextView;
public class MultiAutoCompleteTextViewActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] str = { "Andoid", "Jelly Bean", "Froyo", "Ginger Bread",
"Eclipse Indigo", "Eclipse Juno", "About Eclipse",
"Mobile Android", "Mobile Window", "Smart Phone" };
MultiAutoCompleteTextView mltatotv = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
mltatotv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
ArrayAdapter<String> adptr = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, str);
mltatotv.setThreshold(1);
mltatotv.setAdapter(adptr);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anju.tiwari.multiautocompletetextview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:screenOrientation="portrait"
android:name="com.anju.tiwari.multiautocompletetextview.MultiAutoCompleteTextViewActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Multi Auto Complete TextView"
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:textColor="#336633"
android:textStyle="bold"
android:textSize="20sp"/>
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="MultiAutoCompleteTextView"
android:layout_gravity="center"
android:layout_marginTop="40dp" >
<requestFocus />
</MultiAutoCompleteTextView>
</LinearLayout>
MultiAutoCompleteTextViewActivity.java
package com.anju.tiwari.multiautocompletetextview;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.MultiAutoCompleteTextView;
public class MultiAutoCompleteTextViewActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] str = { "Andoid", "Jelly Bean", "Froyo", "Ginger Bread",
"Eclipse Indigo", "Eclipse Juno", "About Eclipse",
"Mobile Android", "Mobile Window", "Smart Phone" };
MultiAutoCompleteTextView mltatotv = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
mltatotv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
ArrayAdapter<String> adptr = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, str);
mltatotv.setThreshold(1);
mltatotv.setAdapter(adptr);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anju.tiwari.multiautocompletetextview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:screenOrientation="portrait"
android:name="com.anju.tiwari.multiautocompletetextview.MultiAutoCompleteTextViewActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
No comments:
Post a Comment