20.11.2016 Views

Android App Development ฉบับสมบูรณ์

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4. รันแอพพลิเคชันแล้วลองคลิกปุ่ม จะสังเกตเห็นได้ว่ารูปภาพเปลี่ยนจากรูปแอนดรอยด์สีน้ำเงิน<br />

เป็นสีเขียวดังรูป<br />

4.2<br />

เปลี่ยนรูป<br />

4.1<br />

คลิก<br />

ImageButton : ปุ่มรูปภาพ<br />

อิลิเมนต์ ImageButton จะแตกต่างจากอิลิเมนต์<br />

Button คือ อิลิเมนต์ Button เป็นปุ่มข้อความ ส่วน<br />

อิลิเมนต์ ImageButton จะเป็นปุ่มรูปภาพ ซึ่งการใช้งาน<br />

อิลิเมนต์ ImageButton สามารถทำได้เช่นเดียวกับ<br />

อิลิเมนต์อื่นๆ ดังนี้<br />

ตัวอย่างแอพพลิเคชันที่ใช้งาน ImageButton<br />

1. คัดลอกรูปภาพที ่ต้องการใช้สร้างปุ่มเข้ามา<br />

ไว้ในส่วนของ res/drawable-hdpi<br />

เพิ่มรูปภาพ 1<br />

104<br />

<strong>Android</strong> <strong>App</strong> <strong>Development</strong> <strong>ฉบับสมบูรณ์</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!