@BindResoure
This annotation can be used with classes derived from:
- android.app.
Activity
- android.app.
Application
- android.app.
Fragment
- android.app.
Service
- android.content.
ContentProvider
- android.support.v4.app.
Fragment
- android.support.v7.widget.
RecyclerView.ViewHolder
- android.view.
View
- io.github.sporklibrary.interfaces.
ContextProvider
It can bind:
-
R.dimen.*
toFloat
orfloat
fields -
R.string.*
toString
fields -
R.drawable.*
toDrawable
fields
You can bind a resource by specifying its id:
@BindResource(R.string.app_name)
private String appName;
Alternatively, you can imply the view id by the field name:
@BindResource
private String app_name;
Example
public class MyActivity extends Activity {
@BindResource(R.string.app_name)
private String appName;
@BindResource
private String app_name;
@BindResource(R.dimen.spork_test_dimension)
private float sporkTestDimension;
@BindResource
private Float spork_test_dimension;
@BindResource(R.drawable.spork_test_drawable)
private Drawable sporkTestDrawable;
@BindResource
private Drawable spork_test_drawable;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Spork.bind(this);
}
}