Reputation: 33
I'm creating programmatically a Huawei map, but despite MapFragment() is a child of Fragment class, the transaction add doesn't recognize it as a Fragment. Here's my code:
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
val mapFragment = MapFragment()
transaction.add(this.frame.id, mapFragment) ---> here is the problem
transaction.commit()
Someone knows the reason?
Upvotes: 1
Views: 246
Reputation: 4585
There are 2 different classes for showing map in fragment:
You must use correct one your activity.
Activity
and you use just FragmentManager
- use MapFragment
AppCompatActivity
and you use SupportFragmentManager
- use SupportMapFragment
Upvotes: 1