0

i wish to change the button background color,textcolor,text size using android code programmatically.

   Button btnLoadMore = new Button(this);
    btnLoadMore.setText("Load More");

    // Adding Load More button to lisview at bottom
    lv.addFooterView(btnLoadMore);

In this above code succesfully set the Load More Text.but i have to wrote below line

btnLoadMore.setTextColor("#FF1493");

means am getting following error

The method setTextColor(int) in the type TextView is not applicable for the arguments 

(String)

How can i resolve this error.please help me.

2 Answers2

0

Use like this:

TextView text = (TextView) findViewById(R.id.text);
text.setTextColor(Color.parseColor("#FFFFFF"));

Check this link: How to set the text color of TextView in code?

Community
  • 1
  • 1
Lokesh
  • 5,180
  • 4
  • 27
  • 42
  • i have to change the background using below line:btnLoadMore.setBackgroundResource(R.drawable.lgnbttn); it is successfully worked for me – user1780331 Oct 30 '12 at 05:37
0

Try:

Color.ParseColor("color hex value");
Frxstrem
  • 38,761
  • 9
  • 79
  • 119
jigar
  • 1,571
  • 6
  • 23
  • 46