Daily Archives: มีนาคม 6, 2011
Android: Get Resources by Name ( getIdentifier(…); )
Get Resources by Name ( getIdentifier(…); )
สำหรับมือใหม่หัดแอนดรอย ที่เคยใช้แต่ R.drawable. imageName และกำลังกังวลกับการเก็บค่ารูปภาพต่างๆ ลงฐานข้อมูลหรือเท็กไฟล์ ว่าจะเก็บใส่เป็นค่า R.drawable id ดีหรือป่าว น่า ถ้าอย่างนั้นจะต้องเอารูปมาใส่โปรเจ็คก่อนแล้วค่อยก้อปค่า R.drawable id ไปใส่ในฐานข้อมูล แต่ก่อนผมทำอย่างนี้หละ 555+ ยุ่งซะมัดเลย วันนี้เลยมาหาฟังก์ชั่น ที่ได้ค่า id จากการเรียกผ่านชื่อ ดังนั้นหากทำได้เราก้อเก็บชื่อรูปนั้นลงฐานข้อมูลเลยก้อง่ายสุดดดดๆ และวิธีที่ได้คือ resource.getIdentifier นั้นเอง
code
class: Resource (android.content.res.Resources)
method: public int getIdentifier (String name, String defType, String defPackage)
Website: anddev.org
anddev.org
เว็บบอร์ดชมชนนักพัฒนาโปรแกรมบนแอนดรอยครับ มีครบทุกเรื่อง ทุกปัญหา ทุกวิธีการแก้ไขเลยครับ ลองเข้ามาจอยกับบอร์ดนี้ได้ครับผม
adaydesign :)
Website: Mobile UI Patterns
มี.ค. 6
Posted by adaydesign
Mobile UI Patterns
http://mobile-patterns.com/
Read the rest of this entry →
Share this:
Like this:
เขียนใน Recommend Website
ใส่ความเห็น
ป้ายกำกับ: Activity Feeds, Airbnb, Beluga, BNTER, brightkite, Check-in Screens, Comment Detail, Edu Walk Throughs, Footfeed, Groupon, http://mobile-patterns.com/, Notifications, oursquare, recco, Scout Mob, SCVNGR, Shop Kick, Sign Up Flows, Skype, Splash Screens, Tunerfish, Twitter, UI that I Heart, User Profiles