MainActivity.java revision 858e094f1c695aefdf6a23f522c0f16d81bd79f7
1/*
2 * Copyright (C) 2013 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 */
16package com.android.ex.chips.sample;
17
18import android.os.Bundle;
19import android.text.util.Rfc822Tokenizer;
20import android.widget.MultiAutoCompleteTextView;
21import android.app.Activity;
22
23import com.android.ex.chips.BaseRecipientAdapter;
24import com.android.ex.chips.RecipientEditTextView;
25
26public class MainActivity extends Activity {
27
28    @Override
29    protected void onCreate(final Bundle savedInstanceState) {
30        super.onCreate(savedInstanceState);
31        setContentView(R.layout.activity_main);
32
33        final RecipientEditTextView emailRetv =
34                (RecipientEditTextView) findViewById(R.id.email_retv);
35        emailRetv.setTokenizer(new Rfc822Tokenizer());
36        emailRetv.setAdapter(new BaseRecipientAdapter(this) { });
37
38        final RecipientEditTextView phoneRetv =
39                (RecipientEditTextView) findViewById(R.id.phone_retv);
40        phoneRetv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
41        phoneRetv.setAdapter(
42                new BaseRecipientAdapter(BaseRecipientAdapter.QUERY_TYPE_PHONE, this) { });
43    }
44
45}
46