Home | History | Annotate | Download | only in app
      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 
     17 package com.example.android.supportv7.app;
     18 
     19 import android.os.Bundle;
     20 import android.widget.ArrayAdapter;
     21 import android.widget.AutoCompleteTextView;
     22 import android.widget.MultiAutoCompleteTextView;
     23 
     24 import androidx.appcompat.app.AppCompatActivity;
     25 
     26 import com.example.android.supportv7.Cheeses;
     27 import com.example.android.supportv7.R;
     28 
     29 /**
     30  * This demonstrates the styled text input widgets in AppCompat, such as
     31  * {@link android.widget.EditText}, {@link android.widget.AutoCompleteTextView} and
     32  * {@link android.widget.MultiAutoCompleteTextView}.
     33  */
     34 public class AppCompatWidgetsTextInput extends AppCompatActivity {
     35     @Override
     36     protected void onCreate(Bundle savedInstanceState) {
     37         super.onCreate(savedInstanceState);
     38         setContentView(R.layout.appcompat_widgets_text_input);
     39 
     40         // Fetch the AutoCompleteTextView and set an adapter
     41         AutoCompleteTextView actv = findViewById(
     42                 R.id.widgets_autocompletetextview);
     43         actv.setAdapter(new ArrayAdapter<>(this,
     44                 android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
     45 
     46         // Fetch the MultiAutoCompleteTextView and set an adapter and Tokenizer
     47         MultiAutoCompleteTextView mactv = findViewById(
     48                 R.id.widgets_multiautocompletetextview);
     49         mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
     50         mactv.setAdapter(new ArrayAdapter<>(this,
     51                 android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
     52     }
     53 
     54 }
     55