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

Android實(shí)現(xiàn)自動(dòng)文本框提示功能

 更新時(shí)間:2017年10月20日 14:02:48   作者:konekou  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)自動(dòng)文本框提示功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)自動(dòng)文本框提示的具體代碼,供大家參考,具體內(nèi)容如下

activity_main.xml布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" >
  <!--
   默認(rèn)輸2個(gè)字符才能有提示
   completionThreshold表示只輸入1個(gè)字符后,就有提示
   requestFocus表示界面展開時(shí)焦點(diǎn)直接在第二個(gè)文本框
  -->
  <AutoCompleteTextView
    android:id="@+id/myTextView01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:completionThreshold="1" />
  <MultiAutoCompleteTextView
    android:id="@+id/myTextView02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:completionThreshold="1">
    <requestFocus />

  </MultiAutoCompleteTextView>

</LinearLayout>

代碼實(shí)現(xiàn)

public class MainActivity extends Activity {

  private AutoCompleteTextView myTextView01;
  private MultiAutoCompleteTextView myTextView02;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    myTextView01 = (AutoCompleteTextView) findViewById(R.id.myTextView01);
    myTextView02 = (MultiAutoCompleteTextView) findViewById(R.id.myTextView02);

    String[] str={"xiaohe","xiaowang","xiaoli","zhanghe","zhangmin","zhaojun","lihe","daming"};
    /*
    * 創(chuàng)建適配器
    * 參數(shù)一:上下文
    * 參數(shù)二:提示下位框的樣式,不喜歡可以換android.R.layout.*
    * 參數(shù)三:下拉框中備選的內(nèi)容
    */
    ArrayAdapter<String> adapter=new ArrayAdapter<String>(
    this,
    android.R.layout.simple_dropdown_item_1line,
    str);

    //將Adapter設(shè)置到AutoCompleteTextView中
    myTextView01.setAdapter(adapter);

    myTextView02.setAdapter(adapter);
    //以","作為分隔符
    myTextView02.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

家居| 宁化县| 五华县| 安新县| 临洮县| 葫芦岛市| 肇东市| 遵化市| 奉化市| 临清市| 金塔县| 兴隆县| 宁河县| 湾仔区| 房山区| 阳原县| 巴林左旗| 嘉善县| 鹤庆县| 平乐县| 南汇区| 民和| 江源县| 图片| 靖西县| 徐汇区| 浑源县| 兴安县| 云林县| 额济纳旗| 芒康县| 阿城市| 宁乡县| 梅州市| 长白| 仪征市| 福泉市| 大荔县| 莲花县| 淄博市| 石棉县|