1

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

SOYAM APPS
  • 11
  • 2

1 Answers1

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

  1. If Data Binding is being used, then

    FragmentHomeBinding.inflate(inflater, container, false)
    
  2. Otherwise,

    inflater.inflate(R.layout.fragment_home, container, false)
    

Please check Adding a user interface for FRAGMENTS for further details

Sreeji
  • 101
  • 4