0
に私はオプションを有するビューの底から断片をトリガするイベント(新規追加をクリック有し、FundamentalView.csでFundamentalView.axml
のTextViewクリッカブルはMVVMCross
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="22dp"
android:paddingRight="22dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true">
<ImageButton
android:id="@+id/addButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/ic_add_white_24dp" />
</FrameLayout>
のボタンを浮遊しています人と新しい計算)。
var addButton = view.FindViewById<ImageButton>(Resource.Id.addButton);
addButton.Click += OnAddButtonClick;
void OnAddButtonClick(object sender, System.EventArgs e)
{
var dialog = new CardDialogView();
dialog.Show(((MainView)Activity).SupportFragmentManager, "CardDialogView");
}
CardDialogView.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/dash_add_computer"
android:textColor="@color/primary_text"
android:textSize="16sp"
android:text="New Calculation"
local:MvxBind="Click NewCalculationCommand"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/dash_add_head"
android:drawablePadding="28dp"
android:textColor="@color/primary_text"
android:textSize="16sp"
android:text="New Person" />
</LinearLayout>
私の質問は、TextViewにはクリック可能にし、mvvmcrossにクリックしたのTextViewを知る方法ですか?
CardDialogView.cs
public class CardDialogView : MvxDialogFragment<CardDialogViewModel>
{
public override Dialog OnCreateDialog(Bundle savedState)
{
.....
return dialog;
}
}
CardDialogViewModel.cs
public class CardDialogViewModel : MvxViewModel
{
public ICommand NewCalculationCommand
{
get
{
// it does not come here!
return new MvxCommand(() => ShowViewModel<NewItemViewModel>(new { date = DateTime.Now }));
}
}
}
Giorgiありがとうございました。どのテキストビューがクリックされたかをどのように知ることができますか? – hotspring
@hotspring:私の更新答えを見てください。 – Giorgi
素晴らしい!それから私は断片のために 'CardDialogViewModel'を持っている必要があります、そうですか? – hotspring