Design issue Mate....  :(,   Let's say you are receiving some around 20
records and you might wanted to bind in the Listview, you need to do the
following things.

1. Write a class which actually parses your data and bind it to the Model
Class.

2. Create a Class with setters and getters of the fileds you required.

3. While parsing the data make sure you are coping it to the Array
Instances of  the model class, below is some syntax.

         private YourModelClass[] mymodelclass;  //which actually holds the
data
private ArrayAdapter<Planet> listAdapter;//fils this listadapter with the
above model instant and set the adapater to the view.


I would love to give more suggestion in terms of Design.

Kindly let me know , if i can contribute more on this.

-- 
Warm Regards,
*Mukesh Kumar*,
Android Consultant/Freelancer,
India,Hyderabad.



On Sun, Jan 1, 2012 at 7:20 AM, Shawn <[email protected]> wrote:

> I created a simple WCF REST service that is returning a list of data
> rows from a SQL Server. I've been trying to get my android application
> to be able to refernce the returned data for a few days now and
> finally feel like I am getting somehwere. The below code is working
> and the toast text displays the entire response from the web call in a
> comma deliminated format (see bottom for example) but the question is
> how I can individually reference each returned item and how can I fill
> a listview with the results?
>
> public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.runlist);
>        //displayRunList(null); //call the displayRunList function on
> create
>        try {
>                //call our rest service call through httpGet
>        HttpGet request = new HttpGet("http://www.mydomain.com/webserv/
> Service1/getVehicles");
>                        request.setHeader("Accept", "application/json");
>                        request.setHeader("Content-type",
> "application/json");
>                        DefaultHttpClient httpClient = new
> DefaultHttpClient();
>                        HttpResponse response = httpClient.execute(request);
>                        HttpEntity entity = response.getEntity();
>                        Returned = EntityUtils.toString(entity);
>                         Toast.makeText(this, Returned,
> Toast.LENGTH_LONG).show();
>                        Log.i("Test",response.getStatusLine().toString());
>        } catch (IOException ioe) {
>        }
>      }
> //
>
> **************************************************************END********************************************************
>
> When I run the REST service in browswer I am returned with the
> following XML;
>
> - <clsVehicles xmlns="http://schemas.datacontract.org/2004/07/
> WcfRestService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance";>
>  <carNo>A1</carNo>
>  <invNo>262901</invNo>
>  <make>FORD</make>
>  <mileage>117894</mileage>
>  <model>RANGER</model>
>  <saleDate>12/30/2011 12:00:00 AM</saleDate>
>  <sold>True</sold>
>  <style />
>  <year>1994</year>
>  </clsVehicles>
>
>
> The Toast text returns the data like this:
> {"carNo":"A1", "invNo":"262901", "make":"FORD"...............etc}
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to