0

我希望以编程方式使用 android 代码更改按钮背景颜色、文本颜色、文本大小。

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

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

在上面的代码中成功设置了加载更多文本。但我必须在下面写

btnLoadMore.setTextColor("#FF1493");

意味着我得到以下错误

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

(细绳)

我该如何解决这个错误。请帮助我。

4

2 回答 2

0

尝试:

Color.ParseColor("color hex value");
于 2013-07-06T06:01:39.883 回答
0

像这样使用:

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

检查此链接:如何在代码中设置 TextView 的文本颜色?

于 2012-10-30T05:34:14.167 回答