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

68 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
    Replies
    1. Great Article android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  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. 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
  4. 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
  5. Wonderful Information you have given. Please Keep Posting Such Kind of Information. Visit to Know More Click Here
    website design company

    ReplyDelete
  6. 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
  7. Thanks for sharing this useful information
    For top app development company, Visit- EPixel Software Pvt Ltd

    ReplyDelete
  8. Great information shared through this post. It helps me in many ways.Thanks for posting this again. We are top Website Development Company in Delhi | Web Designing Company in Gurgaon.

    ReplyDelete
  9. 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
  10. I wanted to thank you for this great read. Your blog is one of the finest blogs . Thanks for posting this informative article.
    app development company in bhopal
    Top It companies in Bhopal
    Companies in MPNagar Bhopal

    ReplyDelete
  11. 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
  12. Great post.It seems to be interesting and gave me lot of information,Thank for sharing it.I am looking forward for new articles.keep it up.

    Website Development Company in Bangalore | Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Game Development Companies in Bangalore

    ReplyDelete
  13. Great post with unique information.This blog will really helpful for me to develop my skills in a right way.Thanks for sharing,keep update with your blogs.

    Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Website Development Company in Bangalore

    ReplyDelete
  14. 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
  15. Nice post. It is really interesting. Thanks for sharing the post!
    Buy AC Online | Smart LED TV
    Laptops for Sale | Best Inverter AC

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

    ReplyDelete
  17. 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
  18. 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
  19. 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
  20. Nice Blog
    Great Information.
    Makeup Course
    #makeupCourse #NutritionCourse #HairCourse #SpaCourse #CosmetologyCourse #NailCourse #AestheticsSkinCourse

    ReplyDelete
  21. Great points, I really found it very useful and help me out. Thank you for sharing. mobile application development

    ReplyDelete
  22. 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
  23. The content is really great. Good job keep collecting importent information about app development companies in india

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

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

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

    ReplyDelete
  27. thank u for sharing...do have a look on 4S IT Solutions. It the best leading services are IT Services, Cloud Services, IT Solutions, IT Training and CyberSecurity in India.
    Visit 4sitsolutions.com/

    ReplyDelete
  28. 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
  29. Appsinvo was founded in 2015 and it is india-based company. Appsinvo is a Top Mobile App Development Company in India, USA and UK that develops unique, easy to use, high functionality and seamless operation that makes your web and mobile app more innovative. Since 2015, we have been delivering our services for the last 5 years in 120 countries and we have developed more than 300 mobile apps that makes more than 150 clients happy and satisfied with our services.
    Mobile App development company in Asia
    Top Mobile App Development Company
    Top Mobile App Development Company in Noida
    Mobile App Development Company in Delhi
    Top Mobile App Development Companies in Australia
    Top Mobile App Development Company in Qatar
    Top Mobile App Development Company in kuwait
    Top Mobile App Development Companies in Sydney
    Mobile App Development Company in Europe
    Mobile App Development Company in Dubai

    ReplyDelete
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. Thanks for sharing this useful info. In22labs (unwind learning labs) is one of the leading E-governance solutions providers in India. We have worked on 100+ portals using the latest technologies. Know more Government apps development providers

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

    ReplyDelete
  38. 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
  39. Really enjoyed reading this article. I appreciate you for sharing this wonderful post. Keep posting.
    App Development Company

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

    ReplyDelete
  41. 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
  42. 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
  43. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site. For more infoMobile App Development

    ReplyDelete
  44. Thanks for sharing very nice blog keep sharing

    view

    ReplyDelete
  45. 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
  46. 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
  47. Techsaga is the best Mobile apps development company Get a mobile app for your business today, to connect with a wider audience. Believing and nurturing, Innovation, Advancement and Growth introducing Technology and much more that we do in our routine to bring awesomeness to every product. We never settle until we achieve best.

    ReplyDelete
  48. Thank you for posting this awesome article. I’m a long time reader but I’ve never been compelled to leave a comment. If you are interested in Top Android App Development Company or want to discuss the importance of Mobile Application in the present scenario, contact anytime.
    You can also contact here, if you are looking forward to Hire Android App Developers
    Mobile App Development Company
    Best Mobile App Development Company in Saudi Arabia

    ReplyDelete
  49. 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
  50. Thank you for this article because it’s really informative, I love reading your article and I hope that I will read some more about this stuff, it’s really informative and very entertaining. thanks a lot and have a great day. A Custom Mobile App Development specializing need a customized Website, Mobile App, or an E-commerce Platform on Wix, WooCommerce, Magento, or Shopify?

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

    ReplyDelete
  52. Software development creates or converts user goals and marketing goals into a good software application that adds value and growth to user requirements. Software development is used to perform functions as per user requirements, including various phases; such as initial market research, planning, modification, architecture, software design, software implementation, testing, etc. Software Development Company in Lucknow. Software development has become indispensable in the business world today; Improves customer service and assists in developing and maintaining closer customer relationships.

    ReplyDelete
  53. Great post! You are sharing amazing information through your blog. I found your excellent writing skills. Our team of professionals is highly experienced in providing English homework help service, visit today!

    ReplyDelete

function foo()
{
}