Reputation: 7559
I have created a Fragment Activity
, It displays Google Map
and does other stuff.
Now i have another Activity
, I want to use all the functionalities of Fragment Activity
into my new Activity
.
If i had Fragment, i would have easily used it in my new layout like following.
<fragment
android:id="@+id/calendarFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.activities.fragments.HeaderFragment"
tools:layout="@layout/header_fragment" />
But now i am using FragmentActivity
, i cannot use above mentioned code, if i use it it gives me following error message
Caused by: java.lang.ClassCastException
and it obvious, as i passing FragmentActivity
into Activity
.
Kindly guide me how to reuse FragmentActivity
Upvotes: 0
Views: 58
Reputation: 28162
One simple way would be to use inheritance. Basically make 1 FragmentActivity as the base and then make implementation A (which you already have) that extends the FragmentActivity and then make implementation B which also extends it but does some things differently. It all depends on how much you want to reuse...
Just to make it completely clear. Your current FragmentActivity will be the base. Implementation A will not change very much, while B might change a lot...
Upvotes: 1