1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.example.android.supportv7.app;
18
19import com.example.android.supportv7.Cheeses;
20import com.example.android.supportv7.R;
21
22import android.os.Bundle;
23import android.support.v7.app.AppCompatActivity;
24import android.widget.ArrayAdapter;
25import android.widget.AutoCompleteTextView;
26import android.widget.MultiAutoCompleteTextView;
27
28/**
29 * This demonstrates the styled text input widgets in AppCompat, such as
30 * {@link android.widget.EditText}, {@link android.widget.AutoCompleteTextView} and
31 * {@link android.widget.MultiAutoCompleteTextView}.
32 */
33public class AppCompatWidgetsTextInput extends AppCompatActivity {
34    @Override
35    protected void onCreate(Bundle savedInstanceState) {
36        super.onCreate(savedInstanceState);
37        setContentView(R.layout.appcompat_widgets_text_input);
38
39        // Fetch the AutoCompleteTextView and set an adapter
40        AutoCompleteTextView actv = findViewById(
41                R.id.widgets_autocompletetextview);
42        actv.setAdapter(new ArrayAdapter<>(this,
43                android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
44
45        // Fetch the MultiAutoCompleteTextView and set an adapter and Tokenizer
46        MultiAutoCompleteTextView mactv = findViewById(
47                R.id.widgets_multiautocompletetextview);
48        mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
49        mactv.setAdapter(new ArrayAdapter<>(this,
50                android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
51    }
52
53}
54