所以我开始研究这个不属于我的项目,我想从一个活动转到一个片段,我尝试了所有我知道但发现但没有任何效果的项目!
这是我想要的课程
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();
}
这就是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>
这是我想去的课程
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;
}
这是 EditProfileFragment
类的XML<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>
答案 0 :(得分:1)
您可以创建新活动/片段活动并将片段附加到新活动中。
请参阅:How do I add a Fragment to an Activity with a programmatically created content view