I think Luksprog is wrong, I have a simple solution to access your custom src components without an erasable, just calling attribute:
attrs.getAttributeResourceValue( "http://schemas.android.com/apk/res/android", "src", 0);
, , jeje.
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
int src_resource = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
this.setImageBitmap(getDrawable(getResources(),src_resource));
}
public static Bitmap getDrawable(Resources res, int id){
return BitmapFactory.decodeStream(res.openRawResource(id));
}
- xml, :
<com.example.com.jfcogato.mycomponent.CustomView
android:id="@+id/tAImageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/big_image_example"/>