Android Learning précis-writers--the third record

Source: Internet
Author: User

  • This note is mainly used to record the use of various controls under Android to facilitate their own query:PS: Note that the listener for each control is not the same! A mistake can cause a program to crash!
    • Spinner: The most important addition to the control is the array of choices:
      • First, create a arrayadapter by two methods of creating Arrayadapter in the second record;
      • The array is then initialized to a drop-down view through the Setdropdownviewresource () function;
      • Finally, through the function Setadapter (), the created Arrayadapter can be set in.
      • The code is as follows:
      • 1Arrayadapter<charsequence> Timearray =NULL;2Timearray=arrayadapter.createfromresource ( This, R.array.playing_time_setting, Android. R.layout.simple_spinner_item);3 //timearray=new arrayadapter<string> (this,android. r.layout.simple_spinner_item,timestring); //two different methods4Timearray.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item);//parameter is a simple drop-down view layout provided by Android5Timesetting.setadapter (Timearray);

      • Spinner drop-down menu select the Listener function of the click, you must not be mistaken, or the program will crash;
        Setonitemselectedlistener (new  Spinner.onitemselectedlistener () {            publicvoid onitemselected (adapterview<?> arg0, View arg1,                    intlong  arg3) {                            }              Public void onnothingselected (adapterview<?> arg0) {                            }        });

Android Learning précis-writers--the third record

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.