Open TheGreenBastard opened 8 years ago
Try get your image from drawable by this resource string
"android.resource://your_package_name/drawable/your_image_name"
nope still not working tried it with and without the .png on the end
but did you tried in HeaderDesign.fromColorResAndDrawable function or HeaderDesign.fromColorResAndUrl?
been using fromColorResAndDrawable, since it errors every time, i even do a test once it fails the first time. I change 2/4 references back to fromColorResAndUrl and 2/4 of the header calls to fromColorResAndDrawable. it still gives me 4 errors every time.
Could you paste here the errors, please?
Try this code:
return HeaderDesign.fromColorResAndDrawable(
R.color.green,
getResources().getDrawable(R.drawable.my_header));
that worked, thank you Murgio. I still get a depreciated error on the getDrawable, but at least it runs. I can work around the depreciation later.
Upon further inspection that doesnt work. I end up showing the first image for case 1 but upon changing tabs the program errors in a 2-4 pages. The remaining drawables never show up while the app is running.
Hi,
This is what I use...
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.myJPGFile);
Drawable bmDrawable = new BitmapDrawable(getResources(), bm);
return HeaderDesign.fromColorResAndDrawable(R.color.red, bmDrawable);
Hope helps.
Shaun
return "HeaderDesign.fromColorResAndDrawable(R.color.red , ContextCompat.getDrawable(context,R.drawable.your_drawable))
This will work for sure
Hello All, Im new here and have been banging my head against the wall for 2 days trying to get this to work. I am trying to change a string value to a drawable value.
The readme doc says i can use fromColorResAndDrawable in place of fromColorResAndUrl
example code that works and pulls the image...
return HeaderDesign.fromColorResAndUrl( R.color.green, "http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
I changed the code to....
return HeaderDesign.fromColorResAndDrawable( R.color.green, "@drawable/my_header");
I receive an error...
required: int,Drawable found: int,String
so I guess what i need to know is how do i return a Drawable rather than a string?
I must have tried it 20 different ways and im at a loss for what to try next. Any help would be greatly appreciated. Thank You.