アクティビティにフラグメントを追加しようとしましたが、Martijn00のexampleを既に見ています。MVVMCross 4.1.4のフラグメントはアクティビティ(Android)に表示されません
私の問題は、アクティビティは表示されますが、フラグメントは表示されず、デバッグモードでは、デバッガはフラグメントのメソッドOnCreateViewを実行していないということです。したがって、フラグメントの属性は使用されますが、フラグメントは使用されません。私は緑の背景だけで私の活動を参照してください。私は間違って何かを確信しているが、6時間後、私はあきらめない、助けをあなたたちに尋ねる:)
フラグメント:
namespace TopDownTodoList.Mobile.Droid.Views.Fragments{
[MvxFragment(typeof(MainViewModel), Resource.Id.content_frame, true)]
[Register("topdowntodolist.mobile.droid.views.fragments.TodoOverviewFragment")]
public class TodoOverviewFragment : MvxFragment<TodoOverviewViewModel>
{
protected int LayoutId => Resource.Layout.f_todo_overview_fragment;
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
this.Init();
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return this.BindingInflate(this.LayoutId, null);
//return inflater.Inflate(this.LayoutId, container, false);
}
public virtual void Init() { }
}}
活動:
namespace TopDownTodoList.Mobile.Droid.Views{
[Activity(Label = "MainView")]
public class MainView : MvvmCross.Droid.FullFragging.Views.MvxActivity<MainViewModel>
{
protected int LayoutId => Resource.Layout.main_view;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(this.LayoutId);
this.Init();
}
public virtual void Init(){}
}}
App.cs:
protected override void RegisterClasses()
{
RegisterAppStart<TodoOverviewViewModel>();
}
のviewmodels:
public class VMName : MvvmCross.Core.ViewModels.MvxViewModel{...}
FragmentLayout(f_todo_overview_fragment):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mvx="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="#0000aa"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"/></LinearLayout>
ActivityLayout(main_view):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="#aa0000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"><FrameLayout
android:id="@+id/content_frame"
android:background="#00bb00"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" /></LinearLayout>
はさらに、setup.csでFragmentPresenterを上書きするようにしてください。 – Cyriac
あなたのためのすべてのあなたのように高速の答えをありがとうございました。フラグメントのリストとOnAttachFragmentsメソッドがあるので、Fragging PackageのMvxActivityがそれらを2つサポートできると考えました。上に、MvxCachingFragmentActivityクラスまたはxxxCompatActivityクラスが見つかりませんでした。 – Timo
古いバージョンのAndroidをサポートする必要がない場合でも、本当にサポートパッケージを使用する必要がありますか?サポートパッケージでのみMvxCachingFragmentActivityを見つけることができるので、私は尋ねています。 – Timo