源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android自动提示控件AutoCompleteTextView

  • 时间:2022-01-17 17:22 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android自动提示控件AutoCompleteTextView
在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextView实现的。 [img]http://files.jb51.net/file_images/article/201612/20161223164928567.jpg?20161123164937[/img]
<AutoCompleteTextView 
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/autotext"
  />

public class MainActivity extends Activity {
private AutoCompleteTextView autotext;
private ArrayAdapter<String> arrayAdapter;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);

    autotext =(AutoCompleteTextView) findViewById(R.id.autotext);
    String [] arr={"aa","aab","aac"};
    arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr);
    autotext.setAdapter(arrayAdapter);
  }

}

[img]http://files.jb51.net/file_images/article/201612/20161223164945723.jpg?20161123164953[/img] 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部