Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone


Android Rating (Vote) and ListView Part 1

Android Rating (Vote) and ListView Part 1 บทความนี้จะเป็นเทคนิคการแสดงผล และ Update ข้อมูลบน ListView ของ Android ในระบบของการ Vote Rating โดยสร้างระบบ Vote ขึ้นมาผ่าน Dialog Popup ซึ่งจะแสดงผลหลังจากที่มีการคลิกที่ Item ของ ListView หลังจากที่แสดง Dialog Popup ที่ประกอบด้วย รูปภาพ และปุ่ม Vote Rating สำหรับให้คะแนน และเมื่อผู้ใช้คลิกที่ Vote เรียบร้อยแล้วข้อมูลจะถูกส่งไป Update ที่ Web Server (PHP กับ mySQL) และหลังจากที่ Update เรียบร้อยแล้ว ในส่วนของ ListView จะมีการ Update RatingBar ที่อยู่ใน ListView ทันที และจะทำการ Update เฉพาะข้อมูลใน Item นั้น ๆ ของ ListView โดยไม่ต้องไป Refresh ข้อมูลทั้ง ListView หรือ เรียกข้อมูลมาจาก Server อีกครั้ง

และในตัวอย่าง Example 1.1 จะเป้นการเพิ่มคุณสมบัติของ RatingBar ที่อยู่ใน ListView คือสามารถทำการคลิกหรือลาก RatingBar ที่อยู่ในแต่ล่ะ Item ของ ListView และข้อมูลจะถูกส่งไป Update ที่ Web Server ทันที (สุดยอดจริง ๆ )

Android Rating (Vote) and ListView Part 1


จากภาพประกอบ เป็นตัวอย่างการแสดงข้อมูลบน ListView และ Dialog Popup สำหรับการ Vote รวมทั้งเขียน Event เพื่อควบคุม RatingBar ในแต่ล่ะ Item ของ ListView

บทความที่น่าสนใจที่เกี่ยวกับ Rating และการ Vote - Android Vote and Rating (PHP and MySQL)



AndroidManifest.xml
1.<uses-permission android:name="android.permission.INTERNET" />

ในการเขียน Android เพื่อติดต่อกับ Internet จะต้องกำหนด Permission ในส่วนนี้ด้วยทุกครั้ง

Web Server (PHP and MySQL)

MySQL Database
01.CREATE TABLE `images` (
02.  `ImageID` int(11) NOT NULL auto_increment,
03.  `ImageName` varchar(50) NOT NULL,
04.  `ImagePath_Thumbnail` varchar(150) NOT NULL,
05.  `ImagePath_FullPhoto` varchar(150) NOT NULL,
06.  `Rating` float NOT NULL,
07.  PRIMARY KEY  (`ImageID`)
08.) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
09. 
10.--
11.-- Dumping data for table `images`
12.--
13. 


โครงสร้างของตารางและข้อมูล

Android Rating (Vote) and ListView Part 1

getGallery.php (ไฟล์สำหรับแสดงข้อมูลบน ListView)
01.<?php
02.    $objConnect = mysql_connect("localhost","root","root");
03.    $objDB = mysql_select_db("mydatabase");
04. 
05.    $strSQL = "SELECT * FROM images WHERE 1  ";
06.    $objQuery = mysql_query($strSQL);
07.    $intNumField = mysql_num_fields($objQuery);
08.    $resultArray = array();
09.    while($obResult = mysql_fetch_array($objQuery))
10.    {
11.        $arrCol = array();
12.        for($i=0;$i<$intNumField;$i++)
13.        {
14.            $arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
15.        }
16.        array_push($resultArray,$arrCol);
17.    }
18.     
19.    mysql_close($objConnect);
20.     
21.    echo json_encode($resultArray);
22.?>


updateRating.php (ไฟล์สำหรับ Update Rating ที่ถูกส่งมาจาก Android Client)
01.<?php
02. 
03.    //$_POST["ImageID"] = "1"; // ImageID
04.    //$_POST["ratingPoint"] = "3.5"; // ratingPoint
05. 
06.    $objConnect = mysql_connect("localhost","root","root");
07.    $objDB = mysql_select_db("mydatabase");
08.     
09.    /*** Update ***/
10.    $strSQL = " UPDATE images SET
11.        Rating = '".$_POST["ratingPoint"]."'
12.        WHERE ImageID = '".$_POST["ImageID"]."'
13.    ";
14. 
15.    $objQuery = mysql_query($strSQL);
16.    if(!$objQuery) // When Error
17.    {
18.        $arr['StatusID'] = "0";
19.        $arr['Error'] = "Cannot save data!";   
20. 
21.            // Return Current Rating
22.            $strSQL = "SELECT * FROM images WHERE 1 AND ImageID = '".$_POST["ImageID"]."'  ";
23.            $objQuery = mysql_query($strSQL);
24.            $obResult = mysql_fetch_array($objQuery);
25.            if($obResult)
26.            {
27.                $arr['Rating'] = $obResult["Rating"];
28.            }
29.            else
30.            {
31.                $arr['Rating'] = "0";  
32.            }
33.    }
34.    else
35.    {
36.     
37.        // Return New Rating Point
38.        $strSQL = "SELECT * FROM images WHERE 1 AND ImageID = '".$_POST["ImageID"]."'  ";
39.        $objQuery = mysql_query($strSQL);
40.        $obResult = mysql_fetch_array($objQuery);
41.        if($obResult)
42.        {
43.            $arr['StatusID'] = "1";
44.            $arr['Error'] = "";
45.            $arr['Rating'] = $obResult["Rating"];  
46.        }
47. 
48.    }
49. 
50.    /**
51.        $arr['StatusID'] // (0=Failed , 1=Complete)
52.        $arr['Error'] // Error Message
53.        $arr['Rating'] // New Rating Point
54.    */
55.     
56.    mysql_close($objConnect);
57.     
58.    echo json_encode($arr);
59.?>




Android Project

Example 1 แสดงข้อมูลบน ListView และคลิกที่รูปภาพบน ListView จะแสดง Popup AlertDialog ในการโหวต

โครงสร้างของไฟล์ทั้งหมด

Android Rating (Vote) and ListView Part 1

ในตัวอย่างนี้มีการใช้ Custom RatingBar ซึ่งจะสร้าง Style ขึ้นมามีรายละเอียดดังนี้

Android Rating (Vote) and ListView Part 1

Icons รูปภาพ ที่จะใช้แสดงบน Custom RatingBar

/res/drawable/ratingstars.xml
01.<?xml version="1.0" encoding="utf-8"?>
02.<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
03.    <item android:id="@+android:id/background"
04.          android:drawable="@drawable/star_empty" />
05.    <item android:id="@+android:id/secondaryProgress"
06.          android:drawable="@drawable/star_empty" />
07.    <item android:id="@+android:id/progress"
08.          android:drawable="@drawable/star_full" />
09.</layer-list>

สร้าง Style อยู่บนไฟล์ ratingstars.xml

/values/string.xml
1.<style name="styleRatingBar" parent="@android:style/Widget.RatingBar">
2.    <item name="android:progressDrawable">@drawable/ratingstars</item>
3.    <item name="android:minHeight">22dip</item>
4.    <item name="android:maxHeight">22dip</item>
5.</style>

เพิ่มคำสั่งชุดนี้ลงใน string.xml

รายละเอียดเพิ่มเติมของ Custom RatingBar สามารถอ่านได้ที่นี่



ออกแบบ XML layout และ Java ดังต่อไปนี้

Android Rating (Vote) and ListView Part 1

activity_main.xml
01.<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
02.    android:id="@+id/tableLayout1"
03.    android:layout_width="fill_parent"
04.    android:layout_height="fill_parent">
05.  
06.    <TableRow
07.      android:id="@+id/tableRow1"
08.      android:layout_width="wrap_content"
09.      android:layout_height="wrap_content" >
10.      
11.     <TextView
12.        android:id="@+id/textView1"
13.        android:layout_width="wrap_content"
14.        android:layout_height="wrap_content"
15.        android:gravity="center"
16.        android:text="ListView and Rating : "
17.        android:layout_span="1"
18.        android:textAppearance="?android:attr/textAppearanceMedium" />
19.             
20.    </TableRow>
21. 
22.    <View
23.        android:layout_height="1dip"
24.        android:background="#CCCCCC" />
25.  
26.  <LinearLayout
27.        android:orientation="horizontal"
28.        android:layout_width="fill_parent"
29.        android:layout_height="wrap_content"
30.        android:layout_weight="0.1">  
31.      
32.     <ListView
33.         android:id="@+id/listView1"
34.         android:layout_width="match_parent"
35.         android:layout_height="wrap_content">
36.     </ListView>
37.             
38.    </LinearLayout>
39. 
40.    <View
41.        android:layout_height="1dip"
42.        android:background="#CCCCCC" />
43.           
44.    <LinearLayout
45.      android:id="@+id/LinearLayout1"
46.      android:layout_width="wrap_content"
47.      android:layout_height="wrap_content"
48.      android:padding="5dip" >
49. 
50.        <TextView
51.            android:id="@+id/textView2"
52.            android:layout_width="wrap_content"
53.            android:layout_height="wrap_content"
54.            android:text="By.. ThaiCreate.Com" />
55. 
56.    </LinearLayout>
57.     
58.</TableLayout>


Android Rating (Vote) and ListView Part 1

activity_dialog.xml
01.<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
02.    xmlns:tools="http://schemas.android.com/tools"
03.    android:id="@+id/layout_dialog"
04.    android:layout_width="match_parent"
05.    android:layout_height="match_parent" >
06. 
07.    <ImageView
08.        android:id="@+id/imageView"
09.        android:layout_width="wrap_content"
10.        android:layout_height="150dp"
11.        android:layout_alignParentTop="true"
12.        android:layout_centerHorizontal="true"
13.        android:layout_marginTop="10dp" />
14. 
15.    <RatingBar
16.        android:id="@+id/ratingBar"
17.        android:layout_width="wrap_content"
18.        android:layout_height="wrap_content"
19.        android:layout_below="@+id/imageView"
20.        android:layout_centerHorizontal="true"
21.        android:layout_marginTop="22dp" />
22.    
23.</RelativeLayout>


activity_column.xml
01.<TableLayout android:id="@+id/tableLayout1"
02.    android:layout_width="fill_parent"
03.    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
04.  
05.    <TableRow
06.        android:layout_width="wrap_content"
07.        android:layout_height="wrap_content" >
08. 
09.        <ImageView
10.            android:id="@+id/ColImgPath"
11.            android:layout_width="wrap_content"
12.            android:layout_height="wrap_content"
13.            />
14.         
15.        <TextView
16.            android:id="@+id/ColImgID"
17.            android:text="Column 1" />
18.         
19.        <TextView
20.            android:id="@+id/ColImgName"
21.            android:text="Column 2" />
22. 
23.        <RatingBar
24.            android:id="@+id/ColratingBar"
25.            style="@style/styleRatingBar"
26.            android:layout_width="wrap_content"
27.            android:layout_height="wrap_content"
28.            android:max="5"
29.            android:numStars="5" />
30.    
31.    </TableRow>
32. 
33.  
34.</TableLayout>




MainActivity.java
001.package com.myapp;
002. 
003.import java.io.BufferedInputStream;
004.import java.io.BufferedOutputStream;
005.import java.io.BufferedReader;
006.import java.io.ByteArrayOutputStream;
007.import java.io.Closeable;
008.import java.io.IOException;
009.import java.io.InputStream;
010.import java.io.InputStreamReader;
011.import java.io.OutputStream;
012.import java.net.URL;
013.import java.util.ArrayList;
014.import java.util.HashMap;
015.import java.util.List;
016. 
017.import org.apache.http.HttpEntity;
018.import org.apache.http.HttpResponse;
019.import org.apache.http.NameValuePair;
020.import org.apache.http.StatusLine;
021.import org.apache.http.client.ClientProtocolException;
022.import org.apache.http.client.HttpClient;
023.import org.apache.http.client.entity.UrlEncodedFormEntity;
024.import org.apache.http.client.methods.HttpGet;
025.import org.apache.http.client.methods.HttpPost;
026.import org.apache.http.impl.client.DefaultHttpClient;
027.import org.apache.http.message.BasicNameValuePair;
028.import org.json.JSONArray;
029.import org.json.JSONException;
030.import org.json.JSONObject;
031. 
032.import android.os.AsyncTask;
033.import android.os.Bundle;
034.import android.os.StrictMode;
035.import android.annotation.SuppressLint;
036.import android.app.Activity;
037.import android.app.AlertDialog;
038.import android.app.Dialog;
039.import android.app.ProgressDialog;
040.import android.content.Context;
041.import android.content.DialogInterface;
042.import android.graphics.Bitmap;
043.import android.graphics.BitmapFactory;
044.import android.util.Log;
045.import android.view.LayoutInflater;
046.import android.view.View;
047.import android.view.Menu;
048.import android.view.ViewGroup;
049.import android.widget.BaseAdapter;
050.import android.widget.ImageView;
051.import android.widget.ListView;
052.import android.widget.RatingBar;
053.import android.widget.TextView;
054.import android.widget.Toast;
055. 
056.public class MainActivity extends Activity {
057. 
058.    public static final int DIALOG_DOWNLOAD_JSON_PROGRESS = 0;
059.    private ProgressDialog mProgressDialog;
060.     
061.    ArrayList<HashMap<String, Object>> MyArrList;
062.     
063.    ListView lstView1;
064. 
065.     
066.    @SuppressLint("NewApi")
067.    @Override
068.    public void onCreate(Bundle savedInstanceState) {
069.        super.onCreate(savedInstanceState);
070.        setContentView(R.layout.activity_main);
071.         
072.        // Permission StrictMode
073.        if (android.os.Build.VERSION.SDK_INT > 9) {
074.            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
075.            StrictMode.setThreadPolicy(policy);
076.        }
077.         
078.        // Download JSON File  
079.        new DownloadJSONFileAsync().execute();
080.         
081.    }
082.        
083.     
084.    @Override
085.    protected Dialog onCreateDialog(int id) {
086.        switch (id) {
087.        case DIALOG_DOWNLOAD_JSON_PROGRESS:
088.            mProgressDialog = new ProgressDialog(this);
089.            mProgressDialog.setMessage("Downloading.....");
090.            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
091.            mProgressDialog.setCancelable(true);
092.            mProgressDialog.show();
093.            return mProgressDialog;
094.        default:
095.            return null;
096.        }
097.    }
098.     
099.    // Show All Content
100.    public void ShowAllContent()
101.    {
102.        // listView1
103.        lstView1 = (ListView)findViewById(R.id.listView1);
104.        lstView1.setAdapter(new ImageAdapter(MainActivity.this,MyArrList));
105.         
106.    }
107.     
108.     
109.    public class ImageAdapter extends BaseAdapter
110.    {
111.        private Context context;
112.        private ArrayList<HashMap<String, Object>> MyArr = new ArrayList<HashMap<String, Object>>();
113.         
114.        public ImageAdapter(Context c, ArrayList<HashMap<String, Object>> myArrList)
115.        {
116.            // TODO Auto-generated method stub
117.            context = c;
118.            MyArr = myArrList;
119.        }
120.  
121.        public int getCount() {
122.            // TODO Auto-generated method stub
123.            return MyArr.size();
124.        }
125.  
126.        public Object getItem(int position) {
127.            // TODO Auto-generated method stub
128.            return position;
129.        }
130.  
131.        public long getItemId(int position) {
132.            // TODO Auto-generated method stub
133.            return position;
134.        }
135.        public View getView(final int position, View convertView, ViewGroup parent) {
136.            // TODO Auto-generated method stub
137. 
138.            LayoutInflater inflater = (LayoutInflater) context
139.                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
140.          
141.          
142.            if (convertView == null) {
143.                convertView = inflater.inflate(R.layout.activity_column, null);
144.            }
145. 
146.            // ColImage
147.            ImageView imageView = (ImageView) convertView.findViewById(R.id.ColImgPath);
148.            imageView.getLayoutParams().height = 80;
149.            imageView.getLayoutParams().width = 80;
150.            imageView.setPadding(10, 10, 10, 10);
151.            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
152.             try
153.             {
154.                 imageView.setImageBitmap((Bitmap)MyArr.get(position).get("ImageThumBitmap"));
155.             } catch (Exception e) {
156.                 // When Error
157.                 imageView.setImageResource(android.R.drawable.ic_menu_report_image);
158.             }
159.                 
160.             // Click on Image
161.             imageView.setOnClickListener(new View.OnClickListener() {
162.                 public void onClick(View v) {
163.                    String strImageID = MyArr.get(position).get("ImageID").toString();
164.                    String strImageName = MyArr.get(position).get("ImageName").toString();
165.                    String strCurrentRating = MyArr.get(position).get("Rating").toString();
166.                     
167.                    ShowDialogVote(position, strImageID,
168.                            strImageName, strCurrentRating,
169.                            MyArr.get(position).get("ImagePathFull").toString()); // Click Show Dialog Vote
170.                     
171.                 }
172.             });
173.              
174.                 
175.            // ColImgID
176.            TextView txtImgID = (TextView) convertView.findViewById(R.id.ColImgID);
177.            txtImgID.setPadding(5, 0, 0, 0);
178.            txtImgID.setText("ID : " + MyArr.get(position).get("ImageID").toString());
179.             
180.            // ColImgName
181.            TextView txtPicName = (TextView) convertView.findViewById(R.id.ColImgName);
182.            txtPicName.setPadding(5, 0, 0, 0);
183.            txtPicName.setText("Name : " + MyArr.get(position).get("ImageName").toString());   
184.          
185.            // ColratingBar
186.            RatingBar Rating = (RatingBar) convertView.findViewById(R.id.ColratingBar);
187.            Rating.setPadding(10, 0, 0, 0);
188.            Rating.setEnabled(false);
189.            Rating.setMax(5);
190.            Rating.setRating(Float.valueOf(MyArr.get(position).get("Rating").toString()));
191. 
192.            return convertView;
193.                 
194.        }
195. 
196.    }
197.     
198.    // Show Dialog Vote
199.    public void ShowDialogVote(final int position, final String strImageID,
200.            String strImageName,final String strCurrentRating,String FullImagePath)
201.    {
202.         
203.        final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
204.        final AlertDialog.Builder adb = new AlertDialog.Builder(this);
205.        final LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
206.         
207.        final View Viewlayout = inflater.inflate(R.layout.activity_dialog,
208.                (ViewGroup) findViewById(R.id.layout_dialog));   
209.         
210.        final ImageView image = (ImageView)Viewlayout.findViewById(R.id.imageView); // imageView
211.        image.setImageBitmap((Bitmap)loadBitmap(FullImagePath));
212.         
213.        final RatingBar rating = (RatingBar)Viewlayout.findViewById(R.id.ratingBar); // ratingBar
214.        rating.setMax(5);
215.        rating.setNumStars(5);
216.         
217.        popDialog.setIcon(android.R.drawable.btn_star_big_on);
218.        popDialog.setTitle("Vote!! (" + strImageName + ") ");
219.        popDialog.setView(Viewlayout);
220.         
221.        // Button OK
222.        popDialog.setPositiveButton("OK",
223.                new DialogInterface.OnClickListener() {
224.                    public void onClick(DialogInterface dialog, int which) {
225.                         
226.                        // Save Vote
227.                        String url = "https://www.thaicreate.com/android/updateRating.php";
228.                         
229.                        List<NameValuePair> params = new ArrayList<NameValuePair>();
230.                        params.add(new BasicNameValuePair("ImageID", strImageID));
231.                        params.add(new BasicNameValuePair("ratingPoint", String.valueOf(rating.getRating())));
232.                         
233.                        String resultServer  = getHttpPost(url,params);
234.                         
235.                        /** Get result from Server (Return the JSON Code)
236.                         * StatusID = ? [0=Failed,1=Complete]
237.                         * Error    = ? [On case error return custom error message]
238.                         * Rating   = ? [New Reting Point from Server]
239.                         *
240.                         * Eg Save Failed = {"StatusID":"0","Error":"Not Update Data!","Rating":"0"}
241.                         * Eg Save Complete = {"StatusID":"1","Error":"","Rating":"3.5"}
242.                         */
243.                         
244.                        /*** Default Value ***/
245.                        String strStatusID = "0";
246.                        String strError = "Unknow Status!";
247.                        String strRatingPoint = strCurrentRating;
248.                         
249.                        JSONObject c;
250.                        try {
251.                            c = new JSONObject(resultServer);
252.                            strStatusID = c.getString("StatusID");
253.                            strError = c.getString("Error");
254.                            strRatingPoint = c.getString("Rating"); // New Rating from Server
255.                        } catch (JSONException e) {
256.                            // TODO Auto-generated catch block
257.                            e.printStackTrace();
258.                        }
259.                         
260.                        // Prepare Save Data
261.                        if(strStatusID.equals("0"))
262.                        {
263.                            adb.setMessage(strError);
264.                            adb.show();
265.                        }
266.                        else
267.                        {
268.                            Log.d("strRatingPoint",strRatingPoint);
269.                            UpdateNewRatingPoint(position,strRatingPoint); // Update New Rating Point to ListView (By Row Item)
270.                            // Show Toast
271.                            Toast.makeText(MainActivity.this, "Vote Finished (Point : " + rating.getRating() + ")", Toast.LENGTH_LONG).show();
272.                        }
273.                         
274.                        dialog.dismiss();
275.                         
276.                         
277.                    }
278. 
279.                })
280.                 
281.                        // Button Cancel
282.                .setNegativeButton("Cancel",
283.                        new DialogInterface.OnClickListener() {
284.                            public void onClick(DialogInterface dialog, int id) {
285.                                dialog.cancel();
286.                            }
287.                });
288. 
289.        popDialog.create();
290.        popDialog.show();
291.         
292.    }
293.     
294.     
295.    // Update New Rating to ListView
296.    private void UpdateNewRatingPoint(int position,String newRatingPoint){
297.         
298.        View v = lstView1.getChildAt(position - lstView1.getFirstVisiblePosition());
299.         
300.        // Update RatingBar
301.        RatingBar rating = (RatingBar)v.findViewById(R.id.ColratingBar);
302.        rating.setEnabled(true); // Enabled
303.        rating.setRating(Float.valueOf(newRatingPoint));
304.        rating.setEnabled(false); // False
305.    }
306.     
307.     
308.     
309.    // Download JSON in Background
310.    public class DownloadJSONFileAsync extends AsyncTask<String, Void, Void> {
311.         
312.        protected void onPreExecute() {
313.            super.onPreExecute();
314.            showDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
315.        }
316. 
317.        @Override
318.        protected Void doInBackground(String... params) {
319.            // TODO Auto-generated method stub
320.             
321.            String url = "https://www.thaicreate.com/android/getGallery.php";
322.             
323.            JSONArray data;
324.            try {
325.                data = new JSONArray(getJSONUrl(url));
326.                 
327.                MyArrList = new ArrayList<HashMap<String, Object>>();
328.                HashMap<String, Object> map;
329.                 
330.                for(int i = 0; i < data.length(); i++){
331.                    JSONObject c = data.getJSONObject(i);
332.                    map = new HashMap<String, Object>();
333.                    map.put("ImageID", (String)c.getString("ImageID"));
334.                    map.put("ImageName", (String)c.getString("ImageName"));
335.                     
336.                    // Thumbnail Get ImageBitmap To Object
337.                    map.put("ImagePathThum", (String)c.getString("ImagePath_Thumbnail"));
338.                    map.put("ImageThumBitmap", (Bitmap)loadBitmap(c.getString("ImagePath_Thumbnail")));
339.                     
340.                    // Full (for View Popup)
341.                    map.put("ImagePathFull", (String)c.getString("ImagePath_FullPhoto"));
342.                     
343.                    map.put("Rating", (String)c.getString("Rating"));
344.                     
345.                    MyArrList.add(map);
346.                }
347.                 
348.                 
349.            } catch (JSONException e) {
350.                // TODO Auto-generated catch block
351.                e.printStackTrace();
352.            }
353. 
354.            return null;
355.        }
356. 
357.        protected void onPostExecute(Void unused) {
358.            ShowAllContent(); // When Finish Show Content
359.            dismissDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
360.            removeDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
361.        }
362.         
363.    }
364. 
365.    // get Http Post
366.    public String getHttpPost(String url,List<NameValuePair> params) {
367.        StringBuilder str = new StringBuilder();
368.        HttpClient client = new DefaultHttpClient();
369.        HttpPost httpPost = new HttpPost(url);
370.         
371.        try {
372.            httpPost.setEntity(new UrlEncodedFormEntity(params));
373.            HttpResponse response = client.execute(httpPost);
374.            StatusLine statusLine = response.getStatusLine();
375.            int statusCode = statusLine.getStatusCode();
376.            if (statusCode == 200) { // Status OK
377.                HttpEntity entity = response.getEntity();
378.                InputStream content = entity.getContent();
379.                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
380.                String line;
381.                while ((line = reader.readLine()) != null) {
382.                    str.append(line);
383.                }
384.            } else {
385.                Log.e("Log", "Failed to download result..");
386.            }
387.        } catch (ClientProtocolException e) {
388.            e.printStackTrace();
389.        } catch (IOException e) {
390.            e.printStackTrace();
391.        }
392.        return str.toString();
393.    }
394.     
395.     
396.    /*** Get JSON Code from URL ***/
397.    public String getJSONUrl(String url) {
398.        StringBuilder str = new StringBuilder();
399.        HttpClient client = new DefaultHttpClient();
400.        HttpGet httpGet = new HttpGet(url);
401.        try {
402.            HttpResponse response = client.execute(httpGet);
403.            StatusLine statusLine = response.getStatusLine();
404.            int statusCode = statusLine.getStatusCode();
405.            if (statusCode == 200) { // Download OK
406.                HttpEntity entity = response.getEntity();
407.                InputStream content = entity.getContent();
408.                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
409.                String line;
410.                while ((line = reader.readLine()) != null) {
411.                    str.append(line);
412.                }
413.            } else {
414.                Log.e("Log", "Failed to download file..");
415.            }
416.        } catch (ClientProtocolException e) {
417.            e.printStackTrace();
418.        } catch (IOException e) {
419.            e.printStackTrace();
420.        }
421.        return str.toString();
422.    }
423.     
424.    /***** Get Image Resource from URL (Start) *****/
425.    private static final String TAG = "Image";
426.    private static final int IO_BUFFER_SIZE = 4 * 1024;
427.    public static Bitmap loadBitmap(String url) {
428.        Bitmap bitmap = null;
429.        InputStream in = null;
430.        BufferedOutputStream out = null;
431. 
432.        try {
433.            in = new BufferedInputStream(new URL(url).openStream(), IO_BUFFER_SIZE);
434. 
435.            final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
436.            out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
437.            copy(in, out);
438.            out.flush();
439. 
440.            final byte[] data = dataStream.toByteArray();
441.            BitmapFactory.Options options = new BitmapFactory.Options();
442.            //options.inSampleSize = 1;
443. 
444.            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options);
445.        } catch (IOException e) {
446.            Log.e(TAG, "Could not load Bitmap from: " + url);
447.        } finally {
448.            closeStream(in);
449.            closeStream(out);
450.        }
451. 
452.        return bitmap;
453.    }
454. 
455.     private static void closeStream(Closeable stream) {
456.            if (stream != null) {
457.                try {
458.                    stream.close();
459.                } catch (IOException e) {
460.                    android.util.Log.e(TAG, "Could not close stream", e);
461.                }
462.            }
463.        }
464.      
465.     private static void copy(InputStream in, OutputStream out) throws IOException {
466.        byte[] b = new byte[IO_BUFFER_SIZE];
467.        int read;
468.        while ((read = in.read(b)) != -1) {
469.            out.write(b, 0, read);
470.        }
471.    }
472.     /***** Get Image Resource from URL (End) *****/
473.     
474.    @Override
475.    public boolean onCreateOptionsMenu(Menu menu) {
476.        getMenuInflater().inflate(R.menu.activity_main, menu);
477.        return true;
478.    }
479.     
480.}


Screenshot

Android Rating (Vote) and ListView Part 1

กำลังแสดงข้อมูลบน ListView โดยจะแสดงสถานะ ProgressBar ในขณะที่กำลังโหลดข้อมูล

Android Rating (Vote) and ListView Part 1

แสดงข้อมูลบน ListView หลังจากทที่โหลดข้อมูลเรียบร้อยแล้ว สามารถคลิกที่รูปภาพของแต่ล่ะ Item เพื่อเปิด Dialog Popup

Android Rating (Vote) and ListView Part 1

แสดง Dialog Popup พร้อมกับ Vote ในส่วนของ RatingBar

Android Rating (Vote) and ListView Part 1

เมื่อโหวด (Vote) เรียบร้อยแล้ว ListView จะถูก Update ทันที โดยการทำงานจะมีการ Update เฉพาะ Item นั้น ๆ ซึ่งจะไม่ต้อง Refresh ListView ใหม่

01.private void UpdateNewRatingPoint(int position,String newRatingPoint){
02.     
03.    View v = lstView1.getChildAt(position - lstView1.getFirstVisiblePosition());
04.     
05.    // Update RatingBar
06.    RatingBar rating = (RatingBar)v.findViewById(R.id.ColratingBar);
07.    rating.setEnabled(true); // Enabled
08.    rating.setRating(Float.valueOf(newRatingPoint));
09.    rating.setEnabled(false); // False
10.}

จาก Code จะเห็นว่ามีการอ้างอึง Widget ของ RatingBar ที่อยู่ใน ListView เฉพาะ Item ที่อ้างถึง เพาะฉะนั้นวิธีนี้จะเป็นผลดีที่ไม่ต้องมีการโหลดข้อมูล หรอเรียกข้อมูลจาก Server ซ้ำ

Android Rating (Vote) and ListView Part 1

เมื่อกลับไปดู phpMyAdmin เปิดดู MySQL Database บนฝั่ง Web Server จะเห็นว่ามีการ Update Rating ในส่วนของ รายการนั้น ๆ





Example 1.1 เพิ่มคุณสมบัติให้สามารถคลิกบน RatingBar บน ListView เพื่อโหวตได้ทันที

Android Rating (Vote) and ListView Part 1


จากภาพเมื่อคลิกที่ RatingBar ที่อยู่บน ListView จะมีการโหวตข้อมูลทันที และสามารถเลือกรายการหลาย ๆ รายการพร้อมกัน

MainActivity.java
001.package com.myapp;
002. 
003.import java.io.BufferedInputStream;
004.import java.io.BufferedOutputStream;
005.import java.io.BufferedReader;
006.import java.io.ByteArrayOutputStream;
007.import java.io.Closeable;
008.import java.io.IOException;
009.import java.io.InputStream;
010.import java.io.InputStreamReader;
011.import java.io.OutputStream;
012.import java.net.URL;
013.import java.util.ArrayList;
014.import java.util.HashMap;
015.import java.util.List;
016. 
017.import org.apache.http.HttpEntity;
018.import org.apache.http.HttpResponse;
019.import org.apache.http.NameValuePair;
020.import org.apache.http.StatusLine;
021.import org.apache.http.client.ClientProtocolException;
022.import org.apache.http.client.HttpClient;
023.import org.apache.http.client.entity.UrlEncodedFormEntity;
024.import org.apache.http.client.methods.HttpGet;
025.import org.apache.http.client.methods.HttpPost;
026.import org.apache.http.impl.client.DefaultHttpClient;
027.import org.apache.http.message.BasicNameValuePair;
028.import org.json.JSONArray;
029.import org.json.JSONException;
030.import org.json.JSONObject;
031. 
032.import android.os.AsyncTask;
033.import android.os.Bundle;
034.import android.os.StrictMode;
035.import android.annotation.SuppressLint;
036.import android.app.Activity;
037.import android.app.Dialog;
038.import android.app.ProgressDialog;
039.import android.content.Context;
040.import android.graphics.Bitmap;
041.import android.graphics.BitmapFactory;
042.import android.util.Log;
043.import android.view.LayoutInflater;
044.import android.view.View;
045.import android.view.Menu;
046.import android.view.ViewGroup;
047.import android.widget.BaseAdapter;
048.import android.widget.ImageView;
049.import android.widget.ListView;
050.import android.widget.RatingBar;
051.import android.widget.RatingBar.OnRatingBarChangeListener;
052.import android.widget.TextView;
053. 
054.public class MainActivity extends Activity {
055. 
056.    public static final int DIALOG_DOWNLOAD_JSON_PROGRESS = 0;
057.    private ProgressDialog mProgressDialog;
058.     
059.    ArrayList<HashMap<String, Object>> MyArrList;
060.     
061.    ListView lstView1;
062. 
063.     
064.    @SuppressLint("NewApi")
065.    @Override
066.    public void onCreate(Bundle savedInstanceState) {
067.        super.onCreate(savedInstanceState);
068.        setContentView(R.layout.activity_main);
069.         
070.        // Permission StrictMode
071.        if (android.os.Build.VERSION.SDK_INT > 9) {
072.            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
073.            StrictMode.setThreadPolicy(policy);
074.        }
075.         
076.        // Download JSON File  
077.        new DownloadJSONFileAsync().execute();
078.         
079.    }
080.        
081.     
082.    @Override
083.    protected Dialog onCreateDialog(int id) {
084.        switch (id) {
085.        case DIALOG_DOWNLOAD_JSON_PROGRESS:
086.            mProgressDialog = new ProgressDialog(this);
087.            mProgressDialog.setMessage("Downloading.....");
088.            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
089.            mProgressDialog.setCancelable(true);
090.            mProgressDialog.show();
091.            return mProgressDialog;
092.        default:
093.            return null;
094.        }
095.    }
096.     
097.    // Show All Content
098.    public void ShowAllContent()
099.    {
100.        // listView1
101.        lstView1 = (ListView)findViewById(R.id.listView1);
102.        lstView1.setAdapter(new ImageAdapter(MainActivity.this,MyArrList));
103.         
104.    }
105.     
106.     
107.    public class ImageAdapter extends BaseAdapter
108.    {
109.        private Context context;
110.        private ArrayList<HashMap<String, Object>> MyArr = new ArrayList<HashMap<String, Object>>();
111.         
112.        public ImageAdapter(Context c, ArrayList<HashMap<String, Object>> myArrList)
113.        {
114.            // TODO Auto-generated method stub
115.            context = c;
116.            MyArr = myArrList;
117.        }
118.  
119.        public int getCount() {
120.            // TODO Auto-generated method stub
121.            return MyArr.size();
122.        }
123.  
124.        public Object getItem(int position) {
125.            // TODO Auto-generated method stub
126.            return position;
127.        }
128.  
129.        public long getItemId(int position) {
130.            // TODO Auto-generated method stub
131.            return position;
132.        }
133.        public View getView(final int position, View convertView, ViewGroup parent) {
134.            // TODO Auto-generated method stub
135. 
136.            LayoutInflater inflater = (LayoutInflater) context
137.                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
138.          
139.          
140.            if (convertView == null) {
141.                convertView = inflater.inflate(R.layout.activity_column, null);
142.            }
143. 
144.            // ColImage
145.            ImageView imageView = (ImageView) convertView.findViewById(R.id.ColImgPath);
146.            imageView.getLayoutParams().height = 80;
147.            imageView.getLayoutParams().width = 80;
148.            imageView.setPadding(10, 10, 10, 10);
149.            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
150.             try
151.             {
152.                 imageView.setImageBitmap((Bitmap)MyArr.get(position).get("ImageThumBitmap"));
153.             } catch (Exception e) {
154.                 // When Error
155.                 imageView.setImageResource(android.R.drawable.ic_menu_report_image);
156.             }
157.                 
158.            // ColImgID
159.            TextView txtImgID = (TextView) convertView.findViewById(R.id.ColImgID);
160.            txtImgID.setPadding(5, 0, 0, 0);
161.            txtImgID.setText("ID : " + MyArr.get(position).get("ImageID").toString());
162.             
163.            // ColImgName
164.            TextView txtPicName = (TextView) convertView.findViewById(R.id.ColImgName);
165.            txtPicName.setPadding(5, 0, 0, 0);
166.            txtPicName.setText("Name : " + MyArr.get(position).get("ImageName").toString());   
167.          
168.            // ColratingBar
169.            RatingBar Rating = (RatingBar) convertView.findViewById(R.id.ColratingBar);
170.            Rating.setPadding(10, 0, 0, 0);
171.            Rating.setMax(5);
172.            Rating.setRating(Float.valueOf(MyArr.get(position).get("Rating").toString()));
173.             
174.            // When Change Rating Bar
175.            Rating.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
176.                public void onRatingChanged(RatingBar ratingBar, float rating,
177.                        boolean fromUser) {
178.                     
179.                    if(fromUser)
180.                    {
181.                        String strImageID = MyArr.get(position).get("ImageID").toString();
182.                        String strImageName = MyArr.get(position).get("ImageName").toString();
183.                         
184.                         
185.                        // Save Vote
186.                        String url = "https://www.thaicreate.com/android/updateRating.php";
187.                         
188.                        List<NameValuePair> params = new ArrayList<NameValuePair>();
189.                        params.add(new BasicNameValuePair("ImageID", strImageID));
190.                        params.add(new BasicNameValuePair("ratingPoint", String.valueOf(rating)));
191.                         
192.                        String resultServer  = getHttpPost(url,params);
193.                         
194.                        /** Get result from Server (Return the JSON Code)
195.                         * StatusID = ? [0=Failed,1=Complete]
196.                         * Error    = ? [On case error return custom error message]
197.                         * Rating   = ? [New Reting Point from Server]
198.                         *
199.                         * Eg Save Failed = {"StatusID":"0","Error":"Not Update Data!","Rating":"0"}
200.                         * Eg Save Complete = {"StatusID":"1","Error":"","Rating":"3.5"}
201.                         */
202.                         
203.                        /*** Default Value ***/
204.                        String strStatusID = "0";
205.                        String strError = "Unknow Status!";
206.                        String strRatingPoint = "0";
207.                         
208.                        JSONObject c;
209.                        try {
210.                            c = new JSONObject(resultServer);
211.                            strStatusID = c.getString("StatusID");
212.                            strError = c.getString("Error");
213.                            strRatingPoint = c.getString("Rating"); // New Rating from Server
214.                        } catch (JSONException e) {
215.                            // TODO Auto-generated catch block
216.                            e.printStackTrace();
217.                        }
218.                         
219.                        // Prepare Save Data
220.                        if(strStatusID.equals("0"))
221.                        {
222.                            UpdateNewRatingPoint(position,strRatingPoint); // When Error Update Old Rating
223.                        }
224.                        else
225.                        {
226.                            UpdateNewRatingPoint(position,strRatingPoint); // Update New Rating Point to ListView (By Row Item)
227.                        }
228.                    }
229.     
230.                }
231.            });
232. 
233.            return convertView;
234.                 
235.        }
236. 
237.    }
238. 
239.    // Update New Rating to ListView
240.    private void UpdateNewRatingPoint(int position,String newRatingPoint){
241.         
242.        View v = lstView1.getChildAt(position - lstView1.getFirstVisiblePosition());
243.         
244.        // Update RatingBar
245.        RatingBar rating = (RatingBar)v.findViewById(R.id.ColratingBar);
246.        rating.setRating(Float.valueOf(newRatingPoint));
247.    }
248.     
249.     
250.     
251.    // Download JSON in Background
252.    public class DownloadJSONFileAsync extends AsyncTask<String, Void, Void> {
253.         
254.        protected void onPreExecute() {
255.            super.onPreExecute();
256.            showDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
257.        }
258. 
259.        @Override
260.        protected Void doInBackground(String... params) {
261.            // TODO Auto-generated method stub
262.             
263.            String url = "https://www.thaicreate.com/android/getGallery.php";
264.             
265.            JSONArray data;
266.            try {
267.                data = new JSONArray(getJSONUrl(url));
268.                 
269.                MyArrList = new ArrayList<HashMap<String, Object>>();
270.                HashMap<String, Object> map;
271.                 
272.                for(int i = 0; i < data.length(); i++){
273.                    JSONObject c = data.getJSONObject(i);
274.                    map = new HashMap<String, Object>();
275.                    map.put("ImageID", (String)c.getString("ImageID"));
276.                    map.put("ImageName", (String)c.getString("ImageName"));
277.                     
278.                    // Thumbnail Get ImageBitmap To Object
279.                    map.put("ImagePathThum", (String)c.getString("ImagePath_Thumbnail"));
280.                    map.put("ImageThumBitmap", (Bitmap)loadBitmap(c.getString("ImagePath_Thumbnail")));
281.                     
282.                    // Full (for View Popup)
283.                    map.put("ImagePathFull", (String)c.getString("ImagePath_FullPhoto"));
284.                     
285.                    map.put("Rating", (String)c.getString("Rating"));
286.                     
287.                    MyArrList.add(map);
288.                }
289.                 
290.                 
291.            } catch (JSONException e) {
292.                // TODO Auto-generated catch block
293.                e.printStackTrace();
294.            }
295. 
296.            return null;
297.        }
298. 
299.        protected void onPostExecute(Void unused) {
300.            ShowAllContent(); // When Finish Show Content
301.            dismissDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
302.            removeDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
303.        }
304.         
305.    }
306. 
307.    // get Http Post
308.    public String getHttpPost(String url,List<NameValuePair> params) {
309.        StringBuilder str = new StringBuilder();
310.        HttpClient client = new DefaultHttpClient();
311.        HttpPost httpPost = new HttpPost(url);
312.         
313.        try {
314.            httpPost.setEntity(new UrlEncodedFormEntity(params));
315.            HttpResponse response = client.execute(httpPost);
316.            StatusLine statusLine = response.getStatusLine();
317.            int statusCode = statusLine.getStatusCode();
318.            if (statusCode == 200) { // Status OK
319.                HttpEntity entity = response.getEntity();
320.                InputStream content = entity.getContent();
321.                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
322.                String line;
323.                while ((line = reader.readLine()) != null) {
324.                    str.append(line);
325.                }
326.            } else {
327.                Log.e("Log", "Failed to download result..");
328.            }
329.        } catch (ClientProtocolException e) {
330.            e.printStackTrace();
331.        } catch (IOException e) {
332.            e.printStackTrace();
333.        }
334.        return str.toString();
335.    }
336.     
337.     
338.    /*** Get JSON Code from URL ***/
339.    public String getJSONUrl(String url) {
340.        StringBuilder str = new StringBuilder();
341.        HttpClient client = new DefaultHttpClient();
342.        HttpGet httpGet = new HttpGet(url);
343.        try {
344.            HttpResponse response = client.execute(httpGet);
345.            StatusLine statusLine = response.getStatusLine();
346.            int statusCode = statusLine.getStatusCode();
347.            if (statusCode == 200) { // Download OK
348.                HttpEntity entity = response.getEntity();
349.                InputStream content = entity.getContent();
350.                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
351.                String line;
352.                while ((line = reader.readLine()) != null) {
353.                    str.append(line);
354.                }
355.            } else {
356.                Log.e("Log", "Failed to download file..");
357.            }
358.        } catch (ClientProtocolException e) {
359.            e.printStackTrace();
360.        } catch (IOException e) {
361.            e.printStackTrace();
362.        }
363.        return str.toString();
364.    }
365.    
366.     
367.    /***** Get Image Resource from URL (Start) *****/
368.    private static final String TAG = "Image";
369.    private static final int IO_BUFFER_SIZE = 4 * 1024;
370.    public static Bitmap loadBitmap(String url) {
371.        Bitmap bitmap = null;
372.        InputStream in = null;
373.        BufferedOutputStream out = null;
374. 
375.        try {
376.            in = new BufferedInputStream(new URL(url).openStream(), IO_BUFFER_SIZE);
377. 
378.            final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
379.            out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
380.            copy(in, out);
381.            out.flush();
382. 
383.            final byte[] data = dataStream.toByteArray();
384.            BitmapFactory.Options options = new BitmapFactory.Options();
385.            //options.inSampleSize = 1;
386. 
387.            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options);
388.        } catch (IOException e) {
389.            Log.e(TAG, "Could not load Bitmap from: " + url);
390.        } finally {
391.            closeStream(in);
392.            closeStream(out);
393.        }
394. 
395.        return bitmap;
396.    }
397. 
398.     private static void closeStream(Closeable stream) {
399.            if (stream != null) {
400.                try {
401.                    stream.close();
402.                } catch (IOException e) {
403.                    android.util.Log.e(TAG, "Could not close stream", e);
404.                }
405.            }
406.        }
407.      
408.     private static void copy(InputStream in, OutputStream out) throws IOException {
409.        byte[] b = new byte[IO_BUFFER_SIZE];
410.        int read;
411.        while ((read = in.read(b)) != -1) {
412.            out.write(b, 0, read);
413.        }
414.    }
415.     /***** Get Image Resource from URL (End) *****/
416.     
417.    @Override
418.    public boolean onCreateOptionsMenu(Menu menu) {
419.        getMenuInflater().inflate(R.menu.activity_main, menu);
420.        return true;
421.    }
422.     
423.}




Screenshot

Android Rating (Vote) and ListView Part 1

แสดงข้อมูลบน ListView

Android Rating (Vote) and ListView Part 1

สามารถ Drag หรือ Click ที่ RatingBar เพื่อ Vote ข้อมูลในรายการ Item นั้น ๆ และสามารถ คลิกรายการอื่น ๆ ได้เลยโดยไม่ต้องรอให้ข้อมูล Update เสร็จ

Android Rating (Vote) and ListView Part 1

เมื่อตรวจสอบที่ฝั่ง Web Server จะเห็นว่ารายการได้ถูก Update

เพิ่มเติมจาก Example 1.1
ในกรณีที่ทำการโหวตในเวลาติด ๆ กัน ซึ่งจะเกิด Request ซ้ำ ๆ กัน แนะนำให้ใช้พวก Thread หรือ AsyncTask เข้ามาจัดการ Process เหล่านี้ ซึ่งจะทำให้โปรแกรมไม่ค้างในขณะทำงาน

Android Thread and Handler

Android AsyncTask and ProgressBar




.

   
Hate it
Don't like it
It's ok
Like it
Love it
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2012-08-26 12:21:29 / 2017-03-26 22:37:49
  Download : Download  Android Rating (Vote) and ListView Part 1
 Sponsored Links / Related

 
Android Custom Adapter
Rating :

 
Android People Contact List, Name, Phone No, Photo Picture, Email and Address
Rating :

 
Android Rating (Vote) and ListView Part 2 (Member Login and Average Rating)
Rating :

 
Android PhoneGap (jQuery Mobile) Create Convert App from Website(URL)
Rating :

 
Android Capture Image and Camera Capture Screenshot (android.view.SurfaceView)
Rating :

 
Android Pull Down to Refresh And Release to Refresh or Update (Part 1)
Rating :

 
Android Pull Down to Refresh And Release to Update (Part 2 , PHP & MySQL)
Rating :


ThaiCreate.Com Forum
Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่