Issue
How to change button text color On Clicking the button using hexa-decimal value? I'm using the below code on MainActivity but not working
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// button.setTextColor(Color.GRAY);
button.setTextColor(Color.(#808080));
}
});
Solution
Try this:
button.setTextColor(Color.parseColor("#ff0000"));
OR
button.setTextColor(0xff0000); //SET CUSTOM COLOR
OR
button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR
OR
<Button android:id="@+id/btn_my_button"
android:text="YOUR_TEXT"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ff0000" /> <-- SET TEXT COLOR HERE -->
Hope this may helps you now
Answered By - InsaneCat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.