Reputation: 1790
I have a module named editormodule
which I have a list of fragments and activities in it. let's say they are named (fragment.MapFragment
) and (activity.EditActivity
). Here is my EditActivity
<FrameLayout
android:id="@+id/mainview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:name="fragment.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:layout="@layout/fragment_map"/>
<include
layout="@layout/actionbar"/>
<include
layout="@layout/bottombar"/>
</FrameLayout>
When I start editActivity from my app (com.mobile.app.Main2Activity) it says
com.mobile.app.Main2Activity.fragment.MapFragment
does not exist. In fact, It is located in the module, not in the app.
things that I have already done: - I have added the module into apps dependencies - I have added EditActivity to manifist.xml file - My app only includes an activity without any extra fragments which could make possible conflicts.
Upvotes: 0
Views: 1436
Reputation: 405
In the XML you need the class and not the name. According to your XML try to replace the fragment section with the following:
<fragment
android:id="@+id/map"
class="com.mobile.app.fragment.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"/>
Edit: The class attribute must include the class path (including the whole package) of your fragment class.
Edit2: It is a good style to call in the onCreateView the layout like the following (in Kolin:
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view = inflater.inflate(R.layout.fragment_your_layout, container, false)
return view
}
Upvotes: 1