zoukankan      html  css  js  c++  java
  • DatePickerDialog、AutoCompleteTextView

      DatePickerDialog选择日期,调用showDialog(int id)方法,会执行onCreateDialog方法:

        @Override
        protected Dialog onCreateDialog(int id) {
          switch(id){
            case DATE_PICKER_ID:
              return new DatePickerDialog(this,onDateSetListener,2015,8,12);
          }
          return super.onCreateDialog(id);
        }
        DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) {
            Toast.makeText(Forme.this, year + "-" + monthOfYear + "-" + dayOfMonth, Toast.LENGTH_SHORT).show();
          }
        };

      AutoCompleteTextView提供供选择的下拉列表:

        首先在XML文件中声明一个AutoCompleteTextView控件

          <AutoCompleteTextView
            android:id="@+id/autocomplete"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"/>

        然后通过findViewById方法将AutoCompleteTextView对象绑定到该控件上:

          private AutoCompleteTextView autoCompleteTextView = null;
          autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.autocomplete);
          List<String> list = new ArrayList<String>();
          list.add("abcd");
          list.add("ddffd");
          ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.list_item,list);    //此处list还可以是String数组
          autoCompleteTextView.setAdapter(adapter);

  • 相关阅读:
    网页打开qq
    正则表达式
    微信小程序 如何使用globalData
    微信小程序中常见的typeof cb == “function” && cb(that.globalData.userInfo)
    MongoDB
    Elasticsearch学习
    Kafka学习之路 (一)Kafka的简介
    mybatis sql语句中转义字符
    定时任务
    mybatis insert into 返回id,useGeneratedKeys,keyColumn,keyProperty,parameterType
  • 原文地址:https://www.cnblogs.com/zhanglei93/p/4725569.html
Copyright © 2011-2022 走看看