简体   繁体   中英

how to change visibility a view in a fragment from the activity

As stated in the title how can change visibility a view in a fragment from the activity?

My code has a launch activity and a fragment. I want to change the visibility of a view inside fragment from activity.

How can do this?

There can be a couple of ways. It would nice if you add some code for the reference. 1st way would be to have a method in the fragment which would have the set the visibility to gone in fragment. In you activity you can get the instance of the fragment by this getSupportFragmentManager().findFragmentById(<container - id>) and then just call the fragment method.

2nd way could be using interface to this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM