Skip to content Skip to sidebar Skip to footer

Disable Button In Fragment From Main Activity

I have 3 buttons in a fragment and I want to disable them from the main activity. I have tried to use the bundle option before replace() newfragment but it created other issues. Ca

Solution 1:

Something like this should do the thing:

ButtonControlsfragment= (ButtonControls)
    getFragmentManager().findFragmentById(R.id.rgb_controls);
fragment.setButtonsGone();

You have to actually implement this setButtonsGone method in ButtonControls. Something as:

public void setButtonsGone() {
    RedUp.setVisibility(View.GONE);
    RedDn.setVisibility(View.GONE);
    GreenUp.setVisibility(View.GONE);
    GreenDn.setVisibility(View.GONE);
    BlueUp.setVisibility(View.GONE);
    BlueDn.setVisibility(View.GONE);
}

Post a Comment for "Disable Button In Fragment From Main Activity"