Get free daily email updates!

Follow us!

Wednesday, January 8, 2014

How To Call Image ID From Drawable Folder Using Code Behind In Android

In Some situation we need to set image code behind, that time you fetch image id without XML file in you code behind. You can set it through the resource and drawable property. See in below examples

You can call this image in your application project’s XML file using XML attributes like: android:drawable and android:icon.

Android always use and support bitmap image file. So whenever you insert image in another format like .png, .jpg, .gif.

.png = preferred
.jpg = acceptable
.gif = discouraged

You can call drawable image id using code behind through the below property and syntax
// image name >> facebook_icon
Resources res = getResources();
Drawable dr = res.getDrawable(R.drawable.facebook_icon);
See below image,

Call Drawable image ID using Code behind in android
Call Drawable image ID using Code behind in android
By the calling Image id you can set image style like “image behind textbox”, “Beckground image”.
Code for Image behind textbox
Resources res = getResources();
Drawable shape = res. getDrawable(R.drawable.gradient_box);

TextView tv = (TextView)findViewByID(R.id.textview);
tv.setBackground(shape);
If you want to make different layout XML file under res folder for different screen size, read this article must useful

40 comments:

  1. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Mobile App Development Company
    Mobile App Development Companies

    ReplyDelete
  2. Thanks for sharing this useful information. It was amazing and wonderful to visit your site. If you are interested to know more about Mobile App Development, then you can check out now!

    ReplyDelete
  3. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care.As always, we appreciate your confidence and trust in us.
    Mobile App Development Company in Dubai
    Android App Development Company in Dubai
    Mobile App Development Company
    Android App Development Company in UAE

    ReplyDelete
  4. Wonderful Information you have given. Please Keep Posting Such Kind of Information. Visit to Know More Click Here
    website design company

    ReplyDelete
  5. Codevian Technologies is a proficient web development company. We don’t just modify web portal; we live and respire them. We have gathered a team of the best and brightest minds in custom website development industry, giving our clients access to the most cutting-edge technology through custom website development. You can rest assured you’re in good hands, as we have years of experience in custom ecommerce website development. We would like to hire web developers. Please do not hesitate to contact us on 9225108952 or contact by email (sales@codevian.com), if you require any additional information. Please visit our website www.codevian.com

    ReplyDelete
  6. Thanks for sharing this useful information
    For top app development company, Visit- EPixel Software Pvt Ltd

    ReplyDelete
  7. Why your thoughts are so brilliant!? I really want what you're doing seems like you bring out the best in other people. Because lots of blog’s I’ve encountered was good but it doesn’t really encouraged people, for that I want to give you this mobile app development maybe you find it helpful somehow.

    ReplyDelete
  8. If you need an Android app development to be created for your business or organizations then you can employ iPhone application engineer that can make you an engaging business application which can drives you to acquire advantage.

    ReplyDelete
  9. Great post thanks for sharing it with us.
    If you are finding for best android app development course in jaipur you can visit our site.

    ReplyDelete
  10. This blog is really unique and informative. I really get amazed to read this.BlockChain & CryptoCirrencies Development

    ReplyDelete
  11. Thanks for sharing this information. your blog is good and I got so much knowledge about Mobile App Development Company Islamabad,
    Mobile App Development Company Islamabad,

    ReplyDelete
  12. Your blog is very awesome. I visited this blog and i saw good knowledge every post. keep sharing!


    have a look at Mobile App Development Services in Delhi

    ReplyDelete
  13. Really nice way to present your blog and information is also too good. Thanks for sharing it. If you are searching for more courses than visit here:-

    Mobile Application Development
    DevOps Solutions
    MVP Development
    IoT App Development
    Voice App Development
    Hire Android Developer

    ReplyDelete
  14. Looking For #Mobile #App to be #developed of your own choice here the Dynamisers Solution is the #best #online agency that provides the best services to clients…CLICK BELOW LINK
    Mobile App Development We Offer!

    ReplyDelete
  15. The content is really great. Good job keep collecting importent information about app development companies in india

    ReplyDelete
  16. Great article, enjoyed reading it. For more reference you can read more about App Development Compaines

    ReplyDelete
  17. Great job done, very informative artilcle. enjoyed reading it. Read more about App developmet Companies

    ReplyDelete
  18. Nice and well written article, it was quite informative. Read more about App development Companies

    ReplyDelete
  19. Nice article and it’s really helpful content for us, keep sharing like this more informational article. If you a looking Leading Mobile App Development Company
    in Delhi NCR. Visit: Mobile App Development Company

    ReplyDelete
  20. Nice article and it’s really helpful content for us, keep sharing like this more informational article. If you a looking Leading Mobile App Development Company
    in Delhi NCR. Visit:Top Mobile App Development Company

    ReplyDelete
  21. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well. iOS Development

    ReplyDelete
  22. Are you struggling to complete your engineering assignments? And you don't have time to write your engineering assignment, Engineering is a career-oriented and complicated discipline. From theoretical knowledge to practical classes, engineering students have a lot on their plates throughout the year. Our engineering assignment writers have attained their engineering degrees from reputed universities. They Can Provide you best assistance for engineering assignment help. Do not hesitate to trust & hire our engineering assignment help services. Myassignmenthelp.com review

    ReplyDelete
  23. Thanks for one marvelous posting!!! I enjoyed reading it... you are a great author...I like it...Keep It Up...For more please visit: Mobile App Development India

    ReplyDelete
  24. Thanks for sharing this information. It will be helpful for those who are unaware about it. . If you looking for best Android app development company, reach out Way2Smile Solutions Best Android App Development Company in Chennai,

    ReplyDelete
  25. I'm amazingly satisfied to reveal this blog. I need to thank you for one time, only for this magnificent read.

    App Development Companies in Austin

    ReplyDelete
  26. Thank You for Sharing this wonderful and much required information in this post.
    Agile DevOps Services

    ReplyDelete
  27. Nice blog, great information. Top database development service agency offers bespoke web applications, mobile apps and responsive websites design and development. Call Today!
    software development company york

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
  29. I really like the fact our industry is growing to a new sector and surprisingly your blog has given it a completely new vision. We are aware that how cloning applications are trending. Whether it is Clubhouse clone app or many more.
    Clone apps are the ideal choice for upcoming entrepreneurs as it gives enormous leverage in marketing and massive scope for customization just like Spotify clone app. Clone app scripts can be developed for almost all leading apps and customized as per your needs. But, you will need time and effort if you have to build one on your own for instance Instacart clone app. Therefore it would be best to find someone who knows what they are doing and is acing the whole situation.

    ReplyDelete
  30. I really liked the blog. It is quite user-friendly and intuitive for the users. I personally believe blogs like this depict the importance of React slack clone and other clone apps. Clone apps are of great importance help businesses to revamp their business by bringing them to the digital world. CLone apps like Instacart clone app, Netflix clone, and several others are delineated with the same features making them the best amongst all. Thanks for sharing this information.

    ReplyDelete
  31. Event networking is the most important feature that attracts the audience. It is networking for which the attendees, exhibitors, speakers attend an event, so build an event app that provides sufficient networking opportunities for the attendees to interact with each other.
    https://eventify.io/top-11-tips-to-find-best-event-apps/

    ReplyDelete
  32. With Eventify, an event networking app, event networking and attendee interactions become more systematic than ever. Users are connected on the basis of mutually common interests.
    https://eventify.io/event-networking/

    ReplyDelete
  33. This is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
    dryer repair services in Islamabad

    ReplyDelete
  34. This comment has been removed by the author.

    ReplyDelete
  35. Thanks for sharing this wonderful information. Keep sharing with us! mobile app development company

    ReplyDelete

function foo()
{
}