简体   繁体   中英

How can I change the TextView text color on the appwidget?

As I mentioned in the title, I cannot change the color of the TextView.(Programmatically)

I've tried the following codes but it doesn't work:

views.setTextColor( R.id.txtPtw2Gunes, context.getResources().getColor( R.color.widgetOrange ) );

views.setTextColor( R.id.txtPtw2Aksam, Color.parseColor( "#e4e4e4" ) );

How can I help you do this?

EDIT: views.setTextColor( R.id.txtPtw2Gunes, context.getResources().getColor( R.color.widgetOrange ) );

Actually the code I added works, but it doesn't work on the emulator. I found it working when I tested it on a real phone.

The subject may be locked.

Perhaps you could try something like:

((TextView)findViewById(R.id.txtPtw2Gunes)).setTextColor(getResources().getColor(R.color.widgetOrange));

or

((TextView)views.findViewById(R.id.txtPtw2Gunes)).setTextColor(getResources().getColor(R.color.widgetOrange));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM