• ANDROID笔记:AutoCompleteTextView的简单使用


     1 package com.example.autotextview;
     2 
     3 import android.app.Activity;
     4 import android.os.Bundle;
     5 import android.widget.ArrayAdapter;
     6 import android.widget.AutoCompleteTextView;
     7 
     8 import com.example.adaptertest.R;
     9 
    10 public class AutoTextActivity extends Activity {
    11     @Override
    12     protected void onCreate(Bundle savedInstanceState) {
    13         // TODO Auto-generated method stub
    14         super.onCreate(savedInstanceState);
    15         setContentView(R.layout.autoconpletetext);
    16         
    17         AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autotext);
    18         ArrayAdapter<String> adapter = new ArrayAdapter<String>(
    19                 AutoTextActivity.this, android.R.layout.simple_list_item_1,new String[]{"java","net","android"});
    20         autoCompleteTextView.setAdapter(adapter);
    21 
    22     }
    23 }
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:orientation="vertical" >
     6 
     7     <AutoCompleteTextView
     8         android:id="@+id/autotext"
     9         android:layout_width="100dp"
    10         android:layout_height="wrap_content"
    11         android:completionHint="选中语言"
    12         android:completionThreshold="1"
    13         android:dropDownHeight="300dp" />
    14     <!-- completionThreshold:输入几个字母时匹配 -->
    15     <!-- dropDownHeight: 提示框高度 -->
    16 
    17 </LinearLayout>
  • 相关阅读:
    react-router刷新页面Cannot GET 问题
    react学习之弹出层
    react学习之js-xlsx导入和导出excel表格
    c#串口通信并处理接收的多个参数
    react与微信小程序
    promise知识点小结
    汇编命令小记
    Firebase-config 在android中的使用
    python:html元素解析
    Toast实现源码解析
  • 原文地址:https://www.cnblogs.com/afluy/p/3374474.html
Copyright © 2020-2023  润新知