BraveQueen05
BraveQueen05

Reputation: 33

Creating a Huawei Map programmatically

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

Answers (1)

mohax
mohax

Reputation: 4585

There are 2 different classes for showing map in fragment:

  1. MapFragment
  2. SupportMapFragment

You must use correct one your activity.

  1. If Activity is just Activity and you use just FragmentManager - use MapFragment
  2. If activity is AppCompatActivity and you use SupportFragmentManager - use SupportMapFragment

Upvotes: 1

Related Questions