I getting full information like Country ID,Country Name & Description from WCF Webservice & i have successfully populate in listview which display Country Name only.Now when i select one of the country name in listview for editing,I must get all of the details like country ID & description but i manage to get country name only.Can anyone please guide me.thanks in advance.
//Populate Country Name in Listview
String jsonInput=wcfItems;
ArrayList<String> listItems = new ArrayList<String>();
try{
JSONArray jsonArray = new JSONArray(jsonInput);
int length = jsonArray.length();
List<String> listContents = new ArrayList<String>(length);
for (int i = 0; i < length; i++)
{
splitItem=jsonArray.getString(i).split(",");
//splitItem[0].toString().trim() -->is ID
//splitItem[2].toString().trim() -->is Description
listContents.add(splitItem[1].toString().trim() ); //Country Name
}
ListView myListView = (ListView) findViewById(R.id.listView1);
myListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listContents));
public void onItemSelected(AdapterView<?> parent, View v, int position,
long id) {
//Didn't get country_ID
String country_ID=parent.getItemAtPosition(position).toString();
//Manage to get country_name only
String country_Name=parent.getItemAtPosition(position).toString();
//Didn't get Description
String country_Description=parent.getItemAtPosition(position).toString();
getRateItems(country_ID,country_Name);
You can track the
jsonArrayas the Activity member, so later in theonItemSelected()you can get the samesplitItemviajsonArray.getString(position).