Reputation: 61
So I started to work on this project that is not mine and I want to go from an activity to a fragment, And I tried everything that I know and found but nothing worked!
This is the class that I want go from
public class ConfirmBookingActivity extends BaseAppCompatActivity implements
View.OnClickListener {
/*
some code
*/
@Override
protected void initUI() {
setContentView(R.layout.activity_order_details);
ButterKnife.bind(this);
/*
...
*/
setListener();
populateData();
}
and this is it XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/FillHeight.FillWidth">
<com.example.ui.toolbar.AppToolbar
android:id="@id/toolbar"
style="@style/FillWidth.WrapHeight" />
<ScrollView
style="@style/FillHeight.FillWidth"
android:layout_below="@id/toolbar">
<RelativeLayout
style="@style/FillWidth.WrapHeight"
android:id="@+id/activity_order_details">
<RelativeLayout...>
</LinearLayout...>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
and this is the class that I want to go to
public class EditProfileFragment extends BaseFragment {
/*
some code
*/
@Override
protected View initUI(LayoutInflater inflater, ViewGroup container) {
if (mView == null) {
mView = inflater.inflate(R.layout.frag_profile_edit, null);
ButterKnife.bind(this, mView);
setOnClickListener();
}
return mView;
}
and this is the XML for the class EditProfileFragment
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/FillHeight.FillWidth">
<LinearLayout>
<LinearLayout...>
<android.base.ui.widget.BaseTextInputLayout...>
<android.base.ui.widget.BaseTextInputLayout...>
<android.base.ui.widget.BaseTextView...>
/*
...
*/
</LinearLayout>
</ScrollView>
Upvotes: 0
Views: 55
Reputation: 104
You can create a new activity / fragmentactivity and attach the fragment in the new activity.
refer this : How do I add a Fragment to an Activity with a programmatically created content view
Upvotes: 1