A
A
Aidyn_DjaGa2020-03-04 17:24:38
Java
Aidyn_DjaGa, 2020-03-04 17:24:38

How to implement button shading (quiz application)?

I am a beginner Android developer. I am writing a quiz app. Faced such a problem:
There is a question + 4 buttons for answer options. I did how to display information about the correctness or incorrectness of the answer.
But I also want that after choosing the answer, the buttons are highlighted - three red (not the correct answer) and one green (correct answer). Please help with advice on how to implement this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2020-03-05
@YuryBorodkin

In this case, you should use the `setBackgroundTintList` method
example

mButton.setBackgroundTintList(getContext().getResources().getColorStateList(R.color.your_xml_name));

your_xml_name.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:color="#000" />
</selector>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question