Я пытаюсь показать MvxListView с пользовательским MvxAdapter во фрагменте, но ListView никогда не отображается. Я отлаживался, и метод GetView в моем адаптере никогда не вызывался. Кто-нибудь может мне помочь?MvxListView с пользовательским MvxAdapter не работает в MvxFragment
Я использую MvvmCross 4.0 и фрагмент пространства имен MvvmCross.Droid.FullFragging.
Мои MvxAdapter
public class OcorrenciasListAdapter : MvxAdapter
{
private Context _context;
public OcorrenciasListAdapter(Context context, IMvxAndroidBindingContext bindingContext) : base(context, bindingContext)
{
_context = context;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
var inflater = LayoutInflater.From(_context);
convertView = inflater.Inflate(Resource.Layout.OcorrenciaItem, parent, false);
var ocorrencia = (Ocorrencia) GetRawItem(position);
var txtViewSintomas = convertView.FindViewById<TextView>(Resource.Id.txtViewSintomas);
StringBuilder textoSintomas = new StringBuilder(ocorrencia.sintomas[0].nome);
if (ocorrencia.sintomas.Count >= 3)
{
for (int i = 1; i < 3; i++)
{
textoSintomas.Append(", ");
textoSintomas.Append(ocorrencia.sintomas[i].nome);
}
}
else
{
for (int i = 1; i < ocorrencia.sintomas.Count; i++)
{
textoSintomas.Append(", ");
textoSintomas.Append(ocorrencia.sintomas[i].nome);
}
}
txtViewSintomas.Text = textoSintomas.ToString();
var txtViewData = convertView.FindViewById<TextView>(Resource.Id.txtViewData);
txtViewData.Text = ocorrencia.cadastro.ToString("dd/MM/yyyy");
if (ocorrencia.confirmadoMedico)
{
var txtViewConfirmado = convertView.FindViewById<TextView>(Resource.Id.txtViewConfirmacao);
txtViewConfirmado.Text = "Confirmado pelo médico";
}
return convertView;
}
}
Мой фрагмент:
public class OcorrenciaView : MvxFragment<OcorrenciaViewModel>
{
private MvxListView _lstViewOcorrencias;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.OcorrenciaView, null);
_lstViewOcorrencias = view.FindViewById<MvxListView>(Resource.Id.lstViewOcorrencias);
var btnAdicionar = view.FindViewById<FloatingActionButton>(Resource.Id.btnAdicionar);
btnAdicionar.AttachToListView(_lstViewOcorrencias);
_lstViewOcorrencias.Adapter = new OcorrenciasListAdapter(Activity, (IMvxAndroidBindingContext)this.BindingContext);
return view;
}
}
Мой макет фрагмент
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:local="http://schemas.android.com/apk/res-auto/AppDemia.Droid"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:gridSpec="1|8|#0093eeff|K:#ee8700ff:16,l:72,l:16,r|S:#83ee00ff:16,0,l:16,56,l:16,0,r"
android:background="@color/appdemia_branco"
android:orientation="vertical"
android:id="@+id/Content">
<com.refractored.fab.FloatingActionButton
android:id="@+id/btnAdicionar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="@drawable/ic_add_mini"
android:tint="@color/appdemia_branco"
local:MvxBind="Click CriarOcorrenciaCommand"
fab:fab_colorNormal="@color/appdemia_laranja"
fab:fab_colorPressed="@color/appdemia_laranjaEscuro" />
<Mvx.MvxListView
android:id="@+id/lstViewOcorrencias"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#aeaeae"
android:dividerHeight="1px"
android:clickable="true"
android:focusableInTouchMode="true"
android:choiceMode="singleChoice"
local:MvxBind="ItemsSource Ocorrencias; SelectedItem ObjEntidade; ItemClick ItenClickCommand; "
local:MvxItemTemplate="@layout/ocorrenciaitem" />
Мой ListView макет Iten
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/appdemia_branco"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/txtViewSintomas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#606060"
android:layout_alignParentLeft="true"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/txtViewData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewSintomas"
android:layout_alignParentRight="true"
android:textColor="#606060"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/txtViewConfirmacao"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewSintomas"
android:textColor="#343434"
android:textSize="10dip"
android:layout_marginTop="1dip"
android:layout_alignParentLeft="true" />