L
L
Lord Drous2016-10-26 23:37:10
Java
Lord Drous, 2016-10-26 23:37:10

How to implement stop and play buttons?

Good evening! the fact is that in my player I need to implement the play / stop function, the play button is standard, it is necessary that when you click on it, the song stops and instead of the play button, stop appears, that is, the buttons change according to their state, Thank you in advance for your answer!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Myvrenik, 2016-10-27
@LorDDrouS

I would use a ToggleButton with a custom selector and put a listener on it .
ToggleButton :

<ToggleButton
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:background="@drawable/toggle_playback"
        android:textOff="@null"
        android:textOn="@null" />

drawable/toggle_playback.xml (where ic_playback_stop and ic_playback_play are your icons)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_playback_stop" android:state_checked="true" />
    <item android:drawable="@drawable/ic_playback_play" android:state_checked="false" />
</selector>

O
one pavel, 2016-10-27
@onepavel

The easiest way
is view.setVisibility(View.Invisible)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question