Android - How to programmatically set button color

后端 未结 3 811
深忆病人
深忆病人 2020-12-16 18:54

I am reading in some data from a REST api and need to generate some buttons based on the information the app receives.

Because I need the same buttons in many Activi

3条回答
  •  再見小時候
    2020-12-16 19:33

    Better if you have the View object (findViewById from R class) transformed info specific object: for example Button. ( the standard way - Button b = (Button) fin...(R.id.sdfsdf) )

    Next just type from a few andro-colors:

     b.setTextColor(Color.parseColor("green"));
    

    or BETTER: FROM RGB

     b.setTextColor(Color.rgb(0xff, 0x66, 0x33));
    

    Everything is in the ctrl+spaceBar in Eclipse :P


    Sorry! Maybe the b.setTextColor(0xff0000) would also works...

提交回复
热议问题