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:/>

    然后通过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);

相关文章:

  • 2021-10-04
  • 2021-09-08
  • 2021-04-17
  • 2022-02-06
  • 2022-02-12
  • 2021-12-29
猜你喜欢
  • 2021-09-07
  • 2021-11-14
  • 2022-03-07
  • 2021-04-08
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案