ListView like Android Market Application with separator and ColdFusion as web server --1
Hi folks. This time I’m presenting a huge post.
This post will cover following things:
- ListView with separator
- Pagination like Android Market application
I know that not all of you knows ColdFusion and its component (cfc), but it is just a server part like your web service code.
The reason behind showing this code is to let you know the implementation of the server part.
In above function, I am returning fix number of records from my database. It is used to pull out ten ten records from a query that has thousands of records.
Now I’m calling this web service like:
http://localhost/cfc/mywebservice.cfc?returnformat=json&method=getJobs¤tPage=5&totalRecord=10
And it returns a data in JSON format like:
{“QUERY”:{“COLUMNS”:["JOBID","JOBTITLE","CREATEDATE","JOBDETAIL"],”DATA”:[["1","Title1","January, 25 2011 10:55:53","Detail is here"],["2","Title2","January, 25 2011 10:55:53","Detail is here"],["3","Title3","January, 20 2011 14:13:10","Detail is here"],["4","Title4","January, 20 2011 14:13:10","Detail is here"],["5","Title5","January, 20 2011 14:13:10","Detail is here"],["6","Title6","January, 20 2011 14:13:10","Detail is here"],["7","Title7","January, 18 2011 16:23:28","Detail is here"],["8","Title8","January, 17 2011 11:22:02","Detail is here"],["9","Title9","January, 11 2011 09:22:32","Detail is here"],["10","Title10","January, 11 2011 09:22:32","Detail is here"]]},”TOTALROWCOUNT”:”120″}
Now we are ready to build Android app.
joblist.xml
01 | <? xml version = "1.0" encoding = "utf-8" ?> |
02 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
03 | android:layout_width = "fill_parent" |
04 | android:layout_height = "fill_parent" |
05 | android:orientation = "vertical" > |
06 | < EditText android:id = "@+id/JobSearch" |
07 | android:layout_height = "wrap_content" |
08 | android:layout_width = "fill_parent" |
09 | android:singleLine = "true" |
10 | android:hint = "Search" /> |
11 | < ListView android:id = "@+id/JobList" |
12 | android:layout_width = "fill_parent" |
13 | android:layout_height = "wrap_content" /> |
14 | < TextView android:id = "@+id/EmptyJobList" android:layout_width = "fill_parent" |
15 | android:layout_height = "fill_parent" android:text = "No Results" android:visibility = "invisible" /> |
16 | </ LinearLayout > |
joblistheader.xml
1 | <? xml version = "1.0" encoding = "utf-8" ?> |
2 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
3 | android:orientation = "vertical" android:layout_width = "fill_parent" |
4 | android:layout_height = "wrap_content" > |
5 | < TextView android:id = "@+id/JobDate" android:layout_width = "fill_parent" |
6 | android:layout_height = "wrap_content" android:gravity = "center" |
7 | style = "?android:attr/listSeparatorTextViewStyle" /> |
8 | </ LinearLayout > |
joblistitem.xml
01 | <? xml version = "1.0" encoding = "utf-8" ?> |
02 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
03 | android:orientation = "vertical" android:layout_width = "fill_parent" |
04 | android:layout_height = "wrap_content" android:paddingRight = "5px" > |
05 | < TextView android:id = "@+id/JobTitle" android:layout_width = "wrap_content" |
06 | android:layout_height = "wrap_content" android:layout_alignParentLeft = "true" |
07 | android:text = "jobTitle" style = "?android:attr/textAppearanceLarge" /> |
08 | < TextView android:id = "@+id/JobDetail" |
09 | android:layout_width = "fill_parent" android:layout_height = "wrap_content" /> |
10 | </ LinearLayout > |
No comments:
Post a Comment