MultiAutoCompleteTextView Tutorial- android
A MultiAutoCompleteTextView is an editable text view, extending
AutoCompleteTextView
, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing.Let's demonstrate a MultiAutoCompleteTextView:
In your layout file you can add it as:
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/autocomplete"
android:layout_marginTop="8dp"
android:hint="multi auto complete text view"
android:id="@+id/multi"
android:ems="10"/>
SO, your activity. java can be as:
public class MainActivity extends AppCompatActivity {
MultiAutoCompleteTextView text1;
String[] languages={"android", "java","IOS","JDBC","C#","C++","C"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text1=(MultiAutoCompleteTextView) findViewById(R.id.multi);
ArrayAdapter adapter=new ArrayAdapter(this, android.R.layout.simple_list_item_1,languages);
text.setThreshold(1);
text1.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
}
You Can watch a video demo at:
0 comments: