--> edit AndroidManifest.xml
Membuat Web Server (PHP dan MySQL)
MySQL Database
CREATE TABLE `images` (
`ImageID` int(11) NOT NULL auto_increment,
`ImageName` varchar(50) NOT NULL,
`ImagePath_Thumbnail` varchar(150) NOT NULL,
`ImagePath_FullPhoto` varchar(150) NOT NULL,
`Rating` float NOT NULL,
PRIMARY KEY (`ImageID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `images`
--
INSERT INTO `images` VALUES (1, 'Image 1', 'http://www.thaicreate.com/android/img1_thum.jpg', 'http://www.thaicreate.com/android/img1_full.jpg', 0);
INSERT INTO `images` VALUES (2, 'Image 2', 'http://www.thaicreate.com/android/img2_thum.jpg', 'http://www.thaicreate.com/android/img2_full.jpg', 0);
INSERT INTO `images` VALUES (3, 'Image 3', 'http://www.thaicreate.com/android/img3_thum.jpg', 'http://www.thaicreate.com/android/img3_full.jpg', 0);
INSERT INTO `images` VALUES (4, 'Image 4', 'http://www.thaicreate.com/android/img4_thum.jpg', 'http://www.thaicreate.com/android/img4_full.jpg', 0);
INSERT INTO `images` VALUES (5, 'Image 5', 'http://www.thaicreate.com/android/img5_thum.jpg', 'http://www.thaicreate.com/android/img5_full.jpg', 0);
INSERT INTO `images` VALUES (6, 'Image 6', 'http://www.thaicreate.com/android/img6_thum.jpg', 'http://www.thaicreate.com/android/img6_full.jpg', 0);
`ImageID` int(11) NOT NULL auto_increment,
`ImageName` varchar(50) NOT NULL,
`ImagePath_Thumbnail` varchar(150) NOT NULL,
`ImagePath_FullPhoto` varchar(150) NOT NULL,
`Rating` float NOT NULL,
PRIMARY KEY (`ImageID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `images`
--
INSERT INTO `images` VALUES (1, 'Image 1', 'http://www.thaicreate.com/android/img1_thum.jpg', 'http://www.thaicreate.com/android/img1_full.jpg', 0);
INSERT INTO `images` VALUES (2, 'Image 2', 'http://www.thaicreate.com/android/img2_thum.jpg', 'http://www.thaicreate.com/android/img2_full.jpg', 0);
INSERT INTO `images` VALUES (3, 'Image 3', 'http://www.thaicreate.com/android/img3_thum.jpg', 'http://www.thaicreate.com/android/img3_full.jpg', 0);
INSERT INTO `images` VALUES (4, 'Image 4', 'http://www.thaicreate.com/android/img4_thum.jpg', 'http://www.thaicreate.com/android/img4_full.jpg', 0);
INSERT INTO `images` VALUES (5, 'Image 5', 'http://www.thaicreate.com/android/img5_thum.jpg', 'http://www.thaicreate.com/android/img5_full.jpg', 0);
INSERT INTO `images` VALUES (6, 'Image 6', 'http://www.thaicreate.com/android/img6_thum.jpg', 'http://www.thaicreate.com/android/img6_full.jpg', 0);
---> getGallery.php ---> updateRating.php
Android Project
Etit Custom RatingBarIcons รูปภาพ ที่จะใช้แสดงบน Custom RatingBar
----> /res/drawable/ratingstars.xml
สร้าง Style อยู่บนไฟล์ ratingstars.xml
---> /values/string.xml
--> activity_main.xml
--->activity_column.xml
-->activity_vote.xml
---->MainActivity.java
--->VoteActivity.java
--->เพิ่ม VoteActivity ลงในไฟล์ AndroidManifest.xml
Screenshot
กำลังแสดงข้อมูลจาก Web Server บน ListView
แสดงข้อมูลบน ListView หลังจากที่ได้โหลดเรียบร้อยแล้ว จะเห็นว่าตอนนี้ข้อมูลคะแนน Point ของ RatingBar จะยังเป็น 0 ให้คลิกเพื่อดูรายละเอียด
คลิกที่ RatingBar เพื่อโหวด และคลิกเลือก ที่ปุ่ม Vote เพื่อส่งคะแนนไปยัง Web Server
หลังจากที่โหวดเรียบร้อยแล้ว
เมื่อกลับมาที่หน้าจอของ ListView ก็จะเห็นว่า RatingBar ได้ขึ้น Point ตามที่ได้โหวตไว้
และเมื่อเปิดดู phpMyAdmin บนฝั่ง Web Server ก็จะเห็นว่ารายการนั้น ๆ ได้ถูก Update ตัว Rating
Download Code ทั้งหมดได้จากส่วนท้ายของบทความ
0 comments:
Post a Comment