最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 自動(dòng)完成文本框的實(shí)例

 更新時(shí)間:2018年01月22日 09:00:50   作者:遲暮有話說  
下面小編就為大家分享一篇Android 自動(dòng)完成文本框的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

Android:自動(dòng)完成文本框

xml文件代碼如下:

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

java文件代碼如下:

package com.example.sample_5_1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AutoCompleteActivity extends AppCompatActivity {
 private static final String[] myStr = new String[]{
   "vae","victory","vision","virtue","vital"
 };
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_auto_complete);
  ArrayAdapter<String> aa = new ArrayAdapter<String>( //創(chuàng)建適配器
    this,           // Context
    android.R.layout.simple_dropdown_item_1line,
    //使用Android自帶的簡(jiǎn)單布局
    myStr);          //資源數(shù)組
  AutoCompleteTextView myAutoCompleteTextView =
    (AutoCompleteTextView) findViewById(R.id.myAutoCompleteTextView);
     //得到控件的引用
  myAutoCompleteTextView.setAdapter(aa); //設(shè)置適配器
  myAutoCompleteTextView.setThreshold(1); //定義需要用戶輸入的字符數(shù)
 }
}

以上這篇Android 自動(dòng)完成文本框的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

客服| 延庆县| 南投市| 孟津县| 安达市| 萨迦县| 尼玛县| 温泉县| 庆云县| 百色市| 大邑县| 泌阳县| 綦江县| 古蔺县| 荆州市| 永济市| 蓝田县| 三亚市| 榆树市| 海原县| 绵阳市| 梅河口市| 济宁市| 杭锦后旗| 麻城市| 凤冈县| 永清县| 华容县| 砀山县| 龙川县| 马关县| 英超| 林芝县| 玉田县| 绥化市| 东光县| 崇信县| 湟源县| 上高县| 新竹县| 楚雄市|