Does exist a similar EventToCommand (behavior's) on Android?
Example Silverlight/WPF:
<i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Commanding:EventToCommand Command="{Binding DataContext.EditEventTypeCommand, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}" CommandParameter="{Binding}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers>
Answer: 1
I'm not sure I have understood your question (I don't know Silverlight) but you can do as follows:
In your XML:
<Button ... android:onClick="onMyButtonClicked".../>
In your java file
public void onMyButtonClicked(View sender) { ... }
There are no other ways to specify event handlers in Android XML, I think. You can specify a lot of properties though.
by : Alexhttp://stackoverflow.com/users/721079Answer: 2
If you are using mvvmcross, then bindings exist for all events which have EventHandler
signatures - so you can just use bindings like:
'Click':{'Path':'MyViewModelCommand'}
There are plenty of examples of this in the samples, plus there are several questions oh here - search for MvvmCross and click.
If you need to bind to an event which has an EventHandler<T>
signature then you can add this yourself - see mvvmcross touch command binding in android
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog