Datepickerdialog, Autocompletetextview

Source: Internet
Author: User

Datepickerdialog Select the date and call the ShowDialog (int id) method, the Oncreatedialog method is executed:

@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 provides a drop-down list to choose from:

First, declare a Autocompletetextview control in the XML file

<autocompletetextview
Android:id= "@+id/autocomplete"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:layout_marginleft= "5DP"/>

The Autocompletetextview object is then bound to the control by means of the Findviewbyid method:

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); Here the list can also be a string array
Autocompletetextview.setadapter (adapter);

Datepickerdialog, Autocompletetextview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.