user940016
user940016

Reputation: 2938

Setting the ToggleButton on/off text to nothing

I'm trying to use this code:

actionToggleButton=new ToggleButton(context);
actionToggleButton.setTextOn(null);
actionToggleButton.setTextOff(null);

But I'm still getting the default text! How can I clear it? Thanks.

Upvotes: 1

Views: 2420

Answers (2)

gMale
gMale

Reputation: 17895

You can also do this in XML via the textOn and textOff attributes:

    <ToggleButton
        android:id="@+id/toggle_filter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textOn="@null"
        android:textOff="@null"/>

Upvotes: 2

Sam
Sam

Reputation: 86948

Try this:

    ToggleButton button = new ToggleButton(this);
    button.setText(null);
    button.setTextOn(null);
    button.setTextOff(null);

Upvotes: 2

Related Questions