EVENT
@Click :點擊事件,只能有0個或1個參數,且參數爲View spa
@Click(R.id.myButton) void myButtonWasClicked() { [...] } @Click void anotherButton() { [...] } @Click void yetAnotherButton(View clickedView) { [...] }
@LongClick
@Touch
AdapterViewEvents
@ItemClick 必須有一個參數,若是這個參數是object類型,意味着adapter.getItem(position) ; 若是是int ,意味着是position
@LongItemClick 必須有一個參數,若是這個參數是object類型,意味着adapter.getItem(position) ; 若是是int ,意味着是position
@ItemSelect 必須有一個或者兩個參數,第一個參數必須是boolean 第二個參數爲adapter.getItem(position) 或者也能夠是int ,意味着是positioncode
@EActivity(R.layout.my_list) public class MyListActivity extends Activity { // ... @ItemClick public void myListItemClicked(MyItem clickedItem) { } @ItemLongClick public void myListItemLongClicked(MyItem clickedItem) { } @ItemSelect public void myListItemSelected(boolean selected, MyItem selectedItem) { } }
或者:orm
@EActivity(R.layout.my_list) public class MyListActivity extends Activity { // ... @ItemClick public void myListItemClicked(int position) { } @ItemLongClick public void myListItemLongClicked(int position) { } @ItemSelect public void myListItemSelected(boolean selected, int position) { } }
SeekBarEvents:
@OnSeekBarProgressChangeblog
@SeekBarProgressChange(R.id.seekBar) void onProgressChangeOnSeekBar(SeekBar seekBar, int progress, boolean fromUser) { // Something Here } @SeekBarProgressChange(R.id.seekBar) void onProgressChangeOnSeekBar(SeekBar seekBar, int progress) { // Something Here } @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2}) void onProgressChangeOnSeekBar(SeekBar seekBar) { // Something Here } @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2}) void onProgressChangeOnSeekBar() { // Something Here }
@SeekBarTouchStart
@SeekBarTouchStop
以上兩個標籤的方法有0個或一個參數 , 一個參數類型爲 SeekBar事件
@FocusChangeip
@FocusChange(R.id.helloTextView) void focusChangedOnHelloTextView(View hello, boolean hasFocus) { // Something Here } @FocusChange void helloTextViewFocusChanged(View hello) { // Something Here } @FocusChange({R.id.editText, R.id.helloTextView}) void focusChangedOnSomeTextViews(View hello, boolean hasFocus) { // Something Here } @FocusChange(R.id.helloTextView) void focusChangedOnHelloTextView() { // Something Here }
@CheckedChangeci
@CheckedChange(R.id.helloCheckBox) void checkedChangeOnHelloCheckBox(CompoundButton hello, boolean isChecked) { // Something Here } @CheckedChange void helloCheckBoxCheckedChanged(CompoundButton hello) { // Something Here } @CheckedChange({R.id.aCheckBox, R.id.helloCheckBox}) void checkedChangedOnSomeCheckBoxs(CompoundButton hello, boolean isChecked) { // Something Here } @CheckedChange(R.id.helloCheckBox) void checkedChangedOnHelloCheckBox() { // Something Here }
@TextChangeget
@TextChange(R.id.helloTextView) void onTextChangesOnHelloTextView(CharSequence text, TextView hello, int before, int start, int count) { // Something Here } @TextChange void helloTextViewTextChanged(TextView hello) { // Something Here } @TextChange({R.id.editText, R.id.helloTextView}) void onTextChangesOnSomeTextViews(TextView tv, CharSequence text) { // Something Here } @TextChange(R.id.helloTextView) void onTextChangesOnHelloTextView() { // Something Here }
@BeforeTextChangeit
@BeforeTextChange(R.id.helloTextView) void beforeTextChangedOnHelloTextView(TextView hello, CharSequence text, int start, int count, int after) { // Something Here } @BeforeTextChange void helloTextViewBeforeTextChanged(TextView hello) { // Something Here } @BeforeTextChange({R.id.editText, R.id.helloTextView}) void beforeTextChangedOnSomeTextViews(TextView tv, CharSequence text) { // Something Here } @BeforeTextChange(R.id.helloTextView) void beforeTextChangedOnHelloTextView() { // Something Here }
@AfterTextChangeio
@AfterTextChange(R.id.helloTextView) void afterTextChangedOnHelloTextView(Editable text, TextView hello) { // Something Here } @AfterTextChange void helloTextViewAfterTextChanged(TextView hello) { // Something Here } @AfterTextChange({R.id.editText, R.id.helloTextView}) void afterTextChangedOnSomeTextViews(TextView tv, Editable text) { // Something Here } @AfterTextChange(R.id.helloTextView) void afterTextChangedOnHelloTextView() { // Something Here }
Option Menu:
@EActivity @OptionsMenu(R.menu.my_menu) public class MyActivity extends Activity { @OptionMenuItem MenuItem menuSearch; @OptionsItem(R.id.menuShare) void myMethod() { // You can specify the ID in the annotation, or use the naming convention } @OptionsItem void homeSelected() { // home was selected in the action bar // The "Selected" keyword is optional } @OptionsItem boolean menuSearch() { menuSearch.setVisible(false); // menuSearch was selected // the return type may be void or boolean (false to allow normal menu processing to proceed, true to consume it here) return true; } @OptionsItem({ R.id.menu_search, R.id.menu_delete }) void multipleMenuItems() { // You can specify multiple menu item IDs in @OptionsItem } @OptionsItem void menu_add(MenuItem item) { // You can add a MenuItem parameter to access it } }