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

Android實現(xiàn)自動文本框提示功能

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

本文實例為大家分享了Android實現(xiàn)自動文本框提示的具體代碼,供大家參考,具體內(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個字符才能有提示
   completionThreshold表示只輸入1個字符后,就有提示
   requestFocus表示界面展開時焦點直接在第二個文本框
  -->
  <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>

代碼實現(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)文章

最新評論

民丰县| 贵定县| 张家口市| 申扎县| 东光县| 晋州市| 丹寨县| 石门县| 普定县| 大悟县| 贵州省| 五河县| 庆城县| 广饶县| 洪洞县| 遵义市| 泉州市| 秦安县| 黄平县| 桦南县| 浑源县| 分宜县| 拉萨市| 桂林市| 缙云县| 房产| 连平县| 临澧县| 安康市| 闽侯县| 赤壁市| 陵川县| 新昌县| 余庆县| 丘北县| 神池县| 肇州县| 金华市| 抚顺县| 托克托县| 瑞金市|