Method onAttach Android

Asked

Viewed 185 times

0

Guys, I’m having trouble using the onattach. I have a view that is set Visible when a button is triggered. I would like this View to disappear at the end of an operation of a Fragment. Look at the Code that will make more sense.

Na Activity:

    private View layoutProgress;

    protected void onCreate(Bundle savedInstanceState){

    layoutProgress = findViewById(R.id.layout_progress);

    layoutProgress.setVisibility(View.GONE);
    }

When the Button is set:

    fragment.getInstance().printScreen();(Função de Tirar foto no fragment)
    layoutProgress.setVisibility(View.VISIBLE);

No Fragment:

Runs the necessary and would like the layoutProgress to disappear.

How do you do that? Sorry about the editing, I’m still learning how to format better.

1 answer

0

I found a way, I’ll post it if anyone needs it

after running the code in Fragment put this code:

    Activity act = getActivity();
    if (act == null) return;
    View layoutProgress = findViewById(R.id.layout_progress);
  • Eduardo, it would be good if you could add this information to your question. This space is reserved for answers.

Browser other questions tagged

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