I've found other answers to this but they where 2 and 6 years old so I didn't know if that was the best option.
I'm making an app that converts a simple integer in hex, oct and binary. The user can choose in which of the three options the integer must be converted to by three buttons located at the top of the Fragment.
The effect that I'm searching for is that if the user presses one of the three Buttons, the one that has been clicked remains of a certain color.
This is my XML code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingRight="16dp"
android:paddingLeft="16dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<Button
android:id="@+id/hex_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/hex_button"/>
<Button
android:id="@+id/binary_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_toRightOf="@id/hex_button"
android:text="@string/binary_button"/>
<Button
android:id="@+id/oct_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_toRightOf="@id/binary_button"
android:text="@string/oct_button"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/converted_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:inputType="number"
android:text="@string/convert_button"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="50dp">
<EditText
android:id="@+id/int_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/integer_edit_text_hint"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="50dp"
android:layout_alignParentBottom="true" >
<EditText
android:id="@+id/converted_number_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
Do I have to make changes in the Java code or just in the XML to achieve this?