简体   繁体   中英

How to generate android resource(string, dimen etc.) using by annotation processing?

I would like generate string resource from annotation.

@StringKey("style1")
void applyStyle1(){...}

After compile project:

<resources>
 <!-- Automatically generated file. DO NOT MODIFY -->
 <!-- Values from product flavor: prod -->
 <string name="style1" translatable="false">style1</string>
</resources>

Value does not matter

Are you trying to achieve something like this ?

@ViewById
EditText myEditText;

@ViewById(R.id.myTextView)
TextView textView;

@StringRes(R.string.hello)
String helloFormat; //helloFormat will have the value of R.string.hello at runtime 

@ColorRes
int androidColor;

@BooleanRes
boolean someBoolean;

@SystemService
NotificationManager notificationManager;

@SystemService
WindowManager windowManager;

If so , then have a look at https://github.com/androidannotations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM