|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-2014 eBusiness Information, Excilys Group |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed To in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package org.androidannotations.annotations; |
| 17 | + |
| 18 | +import java.lang.annotation.ElementType; |
| 19 | +import java.lang.annotation.Retention; |
| 20 | +import java.lang.annotation.RetentionPolicy; |
| 21 | +import java.lang.annotation.Target; |
| 22 | + |
| 23 | +/** |
| 24 | + * Use it on a {@link java.util.List} of {@link android.view.View} or {@link android.view.View} subtype |
| 25 | + * fields in a view related (ie {@link org.androidannotations.annotations.EActivity}, {@link org.androidannotations.annotations.EFragment}, |
| 26 | + * {@link org.androidannotations.annotations.EViewGroup}, ...) annotated class. |
| 27 | + * <p/> |
| 28 | + * The annotation value should be an array of R.id.* fields. |
| 29 | + * <p/> |
| 30 | + * Your code related to injected views should go in an {@link org.androidannotations.annotations.AfterViews} |
| 31 | + * annotated method. |
| 32 | + * <p/> |
| 33 | + * <blockquote> |
| 34 | + * |
| 35 | + * Example : |
| 36 | + * |
| 37 | + * <pre> |
| 38 | + * @EActivity(R.layout.main) |
| 39 | + * public class MyActivity extends Activity { |
| 40 | + * |
| 41 | + * // Injects R.id.myEditText |
| 42 | + * @ViewsById({R.id.edit1, R.id.edit2}) |
| 43 | + * List<EditText> myEditTexts; |
| 44 | + * |
| 45 | + * @ViewsById({R.id.myTextView1, R.id.myOtherTextView}) |
| 46 | + * List<TextView> textViews; |
| 47 | + * |
| 48 | + * @AfterViews |
| 49 | + * void updateTextWithDate() { |
| 50 | + * for (TextView textView : textViews) { |
| 51 | + * textView.setText("Date: " + new Date()); |
| 52 | + * } |
| 53 | + * } |
| 54 | + * } |
| 55 | + * </pre> |
| 56 | + * |
| 57 | + * </blockquote> |
| 58 | + * |
| 59 | + * @see org.androidannotations.annotations.AfterViews |
| 60 | + */ |
| 61 | +@Retention(RetentionPolicy.CLASS) |
| 62 | +@Target(ElementType.FIELD) |
| 63 | +public @interface ViewsById { |
| 64 | + |
| 65 | + int[] value() default ResId.DEFAULT_VALUE; |
| 66 | + |
| 67 | + String[] resName() default ""; |
| 68 | +} |
0 commit comments