I\'m using Google Maps API V2 in an activity wih drop down navigation where the map is on the second position.
I\'m adding the map pragmatically like:
If you want to do it without any listener:
Add Fragment with a TAG
supportFragmentManager
.beginTransaction()
.add(R.id.pagerContainer, UniversalWebViewFragment.newInstance(UniversalWebViewFragment.YOUTUBE_SERACH_URL+"HD trailers"),
"UniversalWebView")
.disallowAddToBackStack()
.commit()
Create a public method in Hosting Activity class which you want to call after fragment is loaded. Here I am calling back a method of my fragment for example
public fun loadURL() {
val webViewFragment = supportFragmentManager
.findFragmentByTag("UniversalWebView")
as UniversalWebViewFragment
webViewFragment.searchOnYoutube("Crysis Warhead")
}
Now inside onViewCreated
Method of your fragment you can simply call that public method of Host activity like this:
(activity as HomeActivity ).loadURL()