This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

วันพฤหัสบดีที่ 18 กันยายน พ.ศ. 2557

Titanium Contact

สวัสดีครับ หลังจากห่างหายจากการเขียน บทความไปหลายสัปดาห์ วันนี้ผมขอกลับเข้าไปเรื่องของContact ใน Mobile Device ของทุก ๆ ท่านก่อนละกันนะครับ โดยปกติแล้วใน OS ไม่ว่าจะทั้ง iOSหรือ Android นั้นจะมีโปรแกรม อยู่หนึ่งตัวสำหรับการจัดเก็บรายชื่อต่าง ๆ สำหรับเอาไว้โทรหา หรือ ทำการ ส่ง Email หรือ อื่น ๆ ซึ่งวันนี้ผมจะเสนอเกี่ยวกับการเข้าถึง รายชื่อต่าง ๆ แบบง่าย ๆ กันครับ


วิธีการเข้าถึงก็สามารถทำได้โดยเขียนคำสั่งแบบนี้ครับ
Titanium.Contacts.showContacts
ส่วนใน Property ของ Function showContact นี้มีดังต่อไปนี้ครับ 
  • animated กำหนดให้เมื่อทำการแสดงผลให้แสดง animation หรือไม่
  • fields  ระบุ Fields ที่ต้องการแบบเฉพาะเจาะจง เช่น address
  • selectedPerson ค่าสำหรับเมื่อรายชื่อนั้นถูกเลือก
เอาหล่ะครับเรามาเร่ิมกันเลยดีกว่า เริ่มแรกนั้นก็ ทำการสร้าง window และ ปุ่มอีก 1 ปุ่มครับ

var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});

var show = Ti.UI.createButton({
title:'Show picker',
top :200
});

จากนั้นก็ทำการใส่เข้าไปใน Window ที่ได้สร้างเอาไว้ครับ
win.add(show);
แล้วก็ทำการเขียน Event ให้กับ ปุ่ม show ด้วยคำสั่งแบบนี้ครับ
show.addEventListener('click', function() {
Titanium.Contacts.showContacts({
animated : true,
});
});
แล้วก็ทำการเปิด window ครับ 
win.open();
จากนั้นทำการ รันขึ้นมาครับ ก็ จะได้หน้าตาโปรแกรมแบบนี้ ครับ ทดลองกดที่ ปุ่ม Show Picker ครับ ก็จะพบกับ Contact List ขึ้นมา