Make spinner and spinner have different background images-------custom spinner to design the spinner! you want

Source: Internet
Author: User

Encountered a problem description:

Spinner style of use, the system comes with is not generally ugly, and the style you designed completely out of sync, but for spinner by changing the background

The way the picture makes it look more beautiful, more in line with our aesthetic design. The problem I encountered was that for item and spinner are designed for the same background picture, if different, when selecting

After item, the value of item will be overwritten with the image in spinner, so that spinner does not get the expected display, but it is not appropriate to have the same background image in spinner and item. The problem is

Make the item in spinner and spinner have a different background picture?

See a drop-down effect that appears when you click Spinner

The item in spinner is dynamically added by Setadapter, and the API itself has a spinneradapter, and it's good to rewrite Getdropdownview!

1, spinner by two layout view from the definition, respectively, is responsible for displaying the spinner (part) and click on the display of the item (two part) of a layout situation

2, rewrite adapter method (online A lot of arrayadapter, but all refer to the Android.r.layout.simple_spinner_item.xml system comes with), is generally inherited baseadapter rewrite GetView () and Getdropdownview this

Two methods. GetView modifies the style shown in spinner (that is, layout of layouts), Getdropdownview determines the style displayed in item.

It is not difficult to recognize the two-point definition of a custom spinner.

The practice of this:

1, define the spinner, set the background for the picture with the triangle as the background color.

2, for GetView and Getdropdownview in the same code (just two of the use of layout is not the same), layout of different points is only the background color is different (GetView layout no background image, Getdropdownview set a gray background image)

This paper mainly solves the problem of spinner custom style, and has a deeper understanding of spinner. Each person encounters a different problem, the solution is not unique, for reference only.

Welcome to shoot Bricks!

Make spinner and spinner have different background images-------custom spinner to design the spinner! you want

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.