android之autoCompleteTextView
16lz
2021-01-23
activity
package com.ghg.autoCompleteTextView;import android.app.Activity;import android.os.Bundle;import android.widget.ArrayAdapter;import android.widget.AutoCompleteTextView;/** * 每次只能输入一个省,每次输入两个字符才显示可选的省份选项, * @author gaohong */public class Day0605_AutoCompleteTextViewActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); initView(); } private String[] arr=new String[]{"henan","hebei","shanxin","shandong"}; AutoCompleteTextView aTextView;private void initView() {// TODO Auto-generated method stubaTextView=(AutoCompleteTextView) findViewById(R.id.actv);ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, arr);aTextView.setAdapter(adapter);}}main.xml
<?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="horizontal" ><TextView android:layout_width="wrap_content" android:layout_height="64dp" android:text="省份" android:textSize="20sp" /><AutoCompleteTextView android:id="@+id/actv" android:layout_width="0dp" android:layout_height="64dp" android:layout_weight="1.0" /></LinearLayout>
更多相关文章
- android 限定 EditText字符输入个数
- Android的字符编码转换问题,Unicode,GB2312,UTF8等
- 【简单的学生管理界面】Android的if语句中有字符串判断
- android实现json数据的解析和把数据转换成json格式的字符串
- Android 时间字符串 转成UTC时间转为指定时间的时间字符串
- Android系统开发小问题-启动过程中android字符没有显示出来 .
- android 字符串数组资源
- Android 中如何得到字符的像素宽度
- Android handler.obtainMessage()传字符串用法