I decided to add admob ad to my project and when creating the onCreate method I get an error - Unresolved reference: setContentView. Although I did everything as in the Google Admob documentation Help, I'm a biginer in Android Studioenter image description here
Asked
Active
Viewed 1,099 times
1
-
https://stackoverflow.com/questions/12108370/how-to-setcontentview-in-a-fragment – Vitaliy-T Nov 07 '20 at 09:47
1 Answers
0
In the AdMob Documentation, it is shown for the Activity.
Please check out setContentView details
In your FRAGMENT case, replace "setContentView(R.layout.activity_main)" with any of the below
If Data Binding is being used, then
FragmentHomeBinding.inflate(inflater, container, false)
Otherwise,
inflater.inflate(R.layout.fragment_home, container, false)
Please check Adding a user interface for FRAGMENTS for further details

Sreeji
- 101
- 4