How to leave a hidden Seek bar until another button is clicked - Android

Asked

Viewed 69 times

0

Hello. I have a silly question, but I will be very grateful to those who help me! I am making an app in which in an Activity I have an image view, several Uttons and a seekbar. The idea is this, I want to set an image in the acorto image view with the button clicked and the value of the bar Seek, for example... Button 1+ seekBar 10 = image x Boot 2 + Seek bar 8 = image y...

For that I thought to leave the seekbar hidden or locked until the buttom is selected. and I would like the button to remain selected... Can anyone help me with this code? how it would look...

1 answer

1

Welcome. I couldn’t exactly reproduce your doubt, so this answer assumes a normal Seekbar and a normal Button.

"I thought about leaving the seekbar hidden or locked until the buttom is selected."

You can set the attribute visibility in the layout and change it with setVisibility(int) when the button is clicked OR set the enabled attribute and change it with setEnabled(Boolean).

<SeekBar
    android:id="@+id/seek_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"
    <!-- android:enabled="false" --> />



Button button = findViewById(R.id.botao);
SeekBar seekBar = findViewById(R.id.seek_bar);
button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        seekBar.setVisibility(View.VISIBLE);
        //seekBar.setEnabled(true);
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.