How Android correctly uses generics and multi-parameter "lazy"

Source: Internet
Author: User

I'm going to implement such a title bar

A total of 4 options, using the layout is a TextView corresponding to a small triangular ImageView, each option is not clicked, the font color is black, the small triangle does not display, click, the font color, the small triangle under the display, while the following layout display the corresponding content.

It is not difficult to implement such logic, but if you write it regularly, the code snippet is long and tedious! I did it later.

Write a generic function that gets list<> to get the layout collection to display

Write a Map generic function that gets TextView and ImageView corresponding bindings

The end is integration, collective change

This invokes

Then we have configured an option, a total of four options, corresponding to four click events, that is, write four times, you only need to change, the incoming integer, the other do not, 0,1,2,3 ...

That's all. The program works perfectly,

How Android correctly uses generics and multi-parameter "lazy"

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.