-
Notifications
You must be signed in to change notification settings - Fork 25
Action Types (Obsolete)
The name of the field use to declare the action, indicates the type of the action
On View Clicked
To indicate that an action will be initiate when a view is Clicked in the user interface, you should end your field name with "Clicked"
@Action
MainActivity btnActionClicked;
In this action you have access to the variable view
that represents the View that was clicked. This can be used for performing more operations over the View itself:
@Action("view.setEnabled(false);")
MainActivity btnActionClicked;
By default, if you simply write your view Id (Ex. "btnAction") it's going to be assumed that the action is initiated by a click over that view. There's also a set of other terminations that can be used for this, these are all the available terminations:
- "Click"
- "_click"
- "Clicked"
- "_clicked"
- "Press"
- "_press"
- "Pressed"
- "_pressed"
On View Long Clicked
To indicate that action will be initiate when a view is Long Clicked in the user interface, you should end your field name with "LongClicked"
@Action
MainActivity btnActionLongClicked;
In this action you have access to the variable view
that represents the View that was clicked.
There's also a set of other terminations that can be used for this, these are all the available terminations:
- "LongClick"
- "_longclick"
- "LongClicked"
- "_longclicked"
- "LongPress"
- "_longpress"
- "LongPressed"
- "_longpressed"
To indicate that an action will be initiate when an item of an AdapterView (Ex. ListView, GridView, Spinner) is Clicked in the user interface, you should end your field name with "ItemClicked"
@Action
MainActivity listViewItemClicked;
In this action you have access to the variable parent
that represents the AdapterView that was clicked, to the variable view
representing the View that was clicked, the variable position
representing the Index of the Item that was clicked, and the variable model
representing the Model that was used to fill that item.
In this example a ListView is populated with a list of User models, and when a User is clicked, it is passed to a ProfileActivity to show information about this user
@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {
@Model
@Populator
List<User> users;
@Action("user=model")
ProfileActivity usersItemClicked;
}
@EActivity(R.layout.activity_profile)
public class ProfileActivity extends Activity {
@Extra
@Populator
User_ user;
}
There's also a set of other terminations that can be used for this, these are all the available terminations:
- "ItemClick"
- "_itemclick"
- "ItemClicked"
- "_itemclicked"
- "ItemPress"
- "_itempress"
- "ItemPressed"
- "_itempressed"
Action Bar Menu
To indicate that an action will be initiate when an the Menu is Clicked in the user interface, you should end your field name with "Menu"
In this example MainActivity is started after the user press the menu with id "main"
@Action
MainActivity mainMenu;
There's also a set of other terminations that can be used for this, these are all the available terminations:
- "Menu"
- "_menu"
- "MenuItem"
- "_menuitem"
To indicate that an action will be initiate when an Event is dispatched you should start your field with the name "on".
In this example MainActivity is started when the event "StartActivity" arrives:
@Action
MainActivity onStartActivity;
In this action you have access to the variable event
representing the arrived event:
In this example, when the event
ShowMessage
arrives, it is shown aToast
with the message field:
@Event("message: String")
ShowMessage showMessageEvent;
@Action("event.getMessage()")
Toast onShowMessage;
There's also a set of other terminations that can be used for this, but you should always start the name with "on", these are all the available terminations:
- "Event"
- "_event"
To indicate that an action will be initiate when a method is executed you should write the method name and end the name with "Method".
In this example MainActivity is started when the "onCreate" is executed:
@Action
MainActivity onCreateMethod;
If you write only the method name, and it doesn't exists a layout Id with that name, the action will be fired also when the method is executed There's also a set of other terminations that can be used for this, these are all the available terminations:
- "Method"
- "_method"
See also
- [About Flow Control (Obsolete)](About Flow Control (Obsolete))
- [Available Actions (Obsolete)](Avaiblable Actions (Obsolete))
- [Action Sequences (Obsolete)](Action Sequences (Obsolete))
Sponsored by DSpot Sp. z o.o. Contact us at [email protected]