Android SetTextColor Invalid _ android SetTextColor () parameter setting mode

Source: Internet
Author: User

When you pass code SetTextColor, if color is a resource file, set fails with no effect

There are two solutions to this situation, a pro-test, both of which are effective


First, the way of annotation

Solve the problem by adding annotations on the method

The code is as follows

Second, the context mode
 

Get getcolorstatelist through the context to solve the problem

The code is as follows

int color = GetContext (). Getresources (). Getcolorstatelist (R.color.reservation_text); Textview.settextcolor (color);

The above two ways can solve this problem ah, hope to some friends to help

Android SetTextColor Invalid _ android SetTextColor () parameter setting mode

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.