码迷,mamicode.com
首页 > 移动开发 > 详细

android常用UI使用案例:AutoCompleteTextView

时间:2015-07-28 14:22:33      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

 

package com.test.androidui;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setTitle("AutoCompleteTextViewActivity");
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, PHNOE);
        AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto_complete);
        textView.setAdapter(adapter);
    }

    static final String[] PHNOE = new String[]
    { "13612312345", "13678945612", "13578945632", "13878965412"};

}

 

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/auto_complete"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>

android常用UI使用案例:AutoCompleteTextView

标签:

原文地址:http://www.cnblogs.com/2015android/p/4682583.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!