一、DatePickerDialog的简单Demo
<AutoCompleteTextView
android:id="@+id/autoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请选择"
/>
二、Java代码
private AutoCompleteTextView autoCompleteTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/***自动提示的简单Demo***/
List<CharSequence> list = new ArrayList<CharSequence>();
list.add("xiaoyezi");
list.add("叶胜华");
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_dropdown_item_1line,list);
autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.autoTextView);
autoCompleteTextView.setAdapter(adapter);
/**DatePickerDialog的Demo*****/
DatePickerDialog dialog = new DatePickerDialog(this, DatePickerDialog.THEME_HOLO_DARK,
onDateListener, 2012,11,21);
dialog.show();
}
private OnDateSetListener onDateListener = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
Log.i("time",""+(datePicker.getYear()==year));
System.out.println(year+"-->"+month);
}
};