Search code examples
androidandroid-fragmentslayoutuiswitch

what is the best way to show settingoptions in fragment


I have a fragment where the user need to add data that wil be saved. But there is a switch where the user can choise if he want to add info. If he wants to, it need to add some Edittext fields in de fragment. Otherwhise it doesn't need to show those fields.

Fragment

What is the best way to do this properly?


Solution

  • When the add "info button" is toggled to show the info buttons, set the visibility property on the "Add info A/B here" TextViews to Visible. When the "info button" is toggled to not show the info buttons, set the visibility to Gone.

    myTextView.setVisibility(View.GONE);
    myTextView.setVisibility(View.VISIBLE);