Android "Hundred yards" 2--basic knowledge accumulation (gradual improvement) 2015-06-15

Source: Internet
Author: User

Java basic knowledge, grammar, basic data types and other aspects are not very grasp, often in some very basic problems toss a good time, recently in the implementation of the "Hundred Yards" program, so dedicated to write a blog to record the daily programming process encountered some weak knowledge points, accumulate each, to fill their weaknesses.

 1.Spinner setting default values

After setting the data adapter to spinner, the system defaults to the first data in the data source as the spinner default, many times we need to customize this default, or we need to control the spinner current value by the way of code, You need to use the SetSelection () function at this time, using the following code:

Spinner_channeal1.setselection (2,true);

For two parameters, the first parameter is the index value of the value you want to set in the data source, the second parameter is set directly to true, and the effect is not studied.

  2.16 Binary decimal

   Recently in the use of the serial port operation of hardware devices, often need to carry out the conversion between different values, each time the use of a universal Baidu to search, and then from a large number of answers to pick out their own needs, very troublesome, tonight using the 16 into the decimal system, hereby recorded, convenient to call later:

Integer.parseint ("000003E8", 16)

This function is also convenient to use, the first parameter is passed in hexadecimal that needs to be converted, and the second parameter is the binary type of the converted data source.

  3. Always confused equals and = =

Often encounter need to determine whether two values are equal, often confuse equlals and = =, with a no, and then use another, inefficient, tonight specifically to study the true face of the two, in fact, it is easy to distinguish: in Java, in addition to the basic data type, everything else is an object, While object variables store references, equivalent to C + + pointers, all when comparing objects, such as String, with = = To compare whether two variables point to the same object, and equals is to compare the contents of two strings is equal . Such as:

String str1 = "Dean"= "Dean"null==null  for Truestr3.equals (  null) will report an exception

Summary (2015-06-15): A good day to write more than 100 lines of true own code, the result of this evening wrote the above two lines, sin ...

Android "hundred yards" 2--basic knowledge accumulation (gradual improvement) 2015-06-15

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.