自己主动完毕文本框(AutoCompleteTextView)

java.lang.Object;

android.view.View;

android.view.TextView;

android.widget.EditText;

android.widget.AutoCompleteTextView;

MultiAutoCompleteTextView;

AutoCompleteTextView 类方法

AutoCompleteTextView 演示样例

完整project:http://download.csdn.net/detail/sweetloveft/9408072

下述程序中主要学习 AutoCompleteTextView 的用法,该控件无法在布局文件里指定 android:entries,临时没有查证有没有其它指定的方法,因此决定採用代码载入。还有一个须要注意 layout 中 <requestFocus /> 的使用。

1.MainActivity.java

package com.sweetlover.activity;

import com.sweetlover.autocompletetextviewdemo.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; public class MainActivity extends Activity { private static final String[] phoneNumber = new String[]{
"111234", "133126", "303404", "796863"
}; private AutoCompleteTextView autoTextView = null; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, phoneNumber);
autoTextView = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
autoTextView.setAdapter(adapter);
}
}

2.activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" > <AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/note"
android:ems="20" > <requestFocus />
<!-- http://zhangkun716717-126-com.iteye.com/blog/802201 -->
</AutoCompleteTextView> </LinearLayout>

3.string.xml

<resources>

    <string name="app_name">AutoCompleteTextViewDemo</string>
<string name="note">输入电话号码</string> </resources>

4.AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sweetlover.autocompletetextviewdemo"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.sweetlover.activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application> </manifest>

阅读《Android 从入门到精通》(12)——自己主动完毕文本框的更多相关文章

  1. Android开发系列(二十):AutoCompleteTextView(自己主动完毕文本框)的功能和使用方法

    当用户输入一定的字符之后,自己主动完毕文本框可以显示一个下拉菜单,供用户从中选择,当用户选择某个菜单项之后,AutoCompleteTextView可以依照用户的选择自己主动填写该文本框 AutoCo ...

  2. Android从入门到精通pdf+书源代码

    不须要积分,免费放送 Android从入门到精通的pdf,入门的好书籍,因为csdn文件大小的限制所以分成了两部分. part1地址:http://download.csdn.net/detail/a ...

  3. android 弹出的软键盘遮挡住EditText文本框的解决方案

    1.android 弹出的软键盘遮挡住EditText文本框的解决方案: 把Activit对应的布局文件filename.xml文件里的控件用比重设置布局.(例如:android:layout_wei ...

  4. Android自己主动提示文本框(AutoCompleteTextView)

    自己主动提示文本框(AutoCompleteTextView)能够加强用户体验,缩短用户的输入时间(百度的搜索框就是这个效果). 首先.在xml中定义AutoCompleteTextView控件: a ...

  5. Android Volley入门到精通:使用Volley加载网络图片

    在上一篇文章中,我们了解了Volley到底是什么,以及它的基本用法.本篇文章中我们即将学习关于Volley更加高级的用法,如何你还没有看过我的上一篇文章的话,建议先去阅读Android Volley完 ...

  6. 阅读《Android 从入门到精通》(9)——多项选择

    多项选择(CheckBox) CheckBox 类是 Button 的子类,层次关系例如以下: android.widget.Button android.widget.CompoundButton ...

  7. 阅读《Android 从入门到精通》(17)——进度条

    进度条(ProgressBar) java.lang.Object; android.view.View; android.widget.ProgressBar; ProgressBar 类方法 Pr ...

  8. 阅读《Android 从入门到精通》(24)——切换图片

    切换图片(ImageSwitcher) java.lang.Object; android.view.View; android.widget.ViewGroup; android.widget.Fr ...

  9. 阅读《Android 从入门到精通》(33)——Intent 分类

    Intent 分类 显式 Intent:Intent("android.intent.action.CALL", Uri.parse("tel:" + stri ...

随机推荐

  1. 利用win10自带的系统配置禁止开机启动项和程序

    一.利用win10自带的系统配置禁止开机启动项和程序     首先打开"运行"对话框,可以通过开始菜单打开运行,也可以按下快捷键WIN+R打开"运行".如下图. ...

  2. RPC 调用简述

    首先了解什么叫RPC,为什么要RPC,RPC是指远程过程调用,也就是说两台服务器A,B,一个应用部署在A服务器上,想要调用B服务器上应用提供的函数/方法,由于不在一个内存空间,不能直接调用,需要通过网 ...

  3. HTTPS协议,TLS协议

    一.HTTPS 协议 HTTPS协议其实就是HTTP over TSL,TSL(Transport Layer Security) 传输层安全协议是https协议的核心. TSL可以理解为SSL (S ...

  4. linux tar命令 压缩、打包、解压 详解

    linux tar命令 压缩.打包.解压 详解 1.常用压缩命令 tar –czvf 压缩后的文件.tar.gz 要压缩的文件 2.常用解压命令 tar –xzvf 解压后的文件.tar.gz [要解 ...

  5. Python学习——列表

    定义:1.列表(list)是由一系列特定顺序排列的元素组成,可以包含字母,数字或者将任何东西加入列表. 2.列表的标识符号为 [ ],函数名称为list 3.列表是有序的 相关概念: 元素:列表中的值 ...

  6. 数据库中float类型字段,转化到前端显示,统一保留两位小数

    客户的一个需求,mybatis查询到的数据库的数据进行转换,采用TypeHandler<T>的方式.float保留两位精度可以采用DecimalFormat 直接贴上最终的解决代码(事情没 ...

  7. c#params应用

    params 是C#开发语言中关键字, params主要的用处是在给函数传参数的时候用,就是当函数的参数不固定的时候. 在方法声明中的 params 关键字之后不允许任何其他参数,并且在方法声明中只允 ...

  8. javaweb-2-Tomcat初步学习与使用

    一.Tomcat服务器简介(此点网上官方有详尽的解释,故此不赘述,以学习使用为主) Apache Jakarta的开源项目 JSP/Servlet容器 二.Tomcat的目录结构 三.启动和停止Tom ...

  9. 魔方NewLife.Cube升级v2.0

    魔方是一套集成权限管理的MVC管理后台,最具特色功能是模版覆盖机制,是XCode实体类的最佳搭档! v2.0.2017.1126   借助Ajax支持高级操作,如:删除选中.批量启用禁用等 用户管理增 ...

  10. cocos2dx3.2移植android

    LOCAL_PATH := $(call my-dir)LOCAL_MYDIR = $(LOCAL_PATH)/../../Classesinclude $(CLEAR_VARS) $(call im ...