我得到了服务器的响应,我存储在列表中。我正在获取整个数据列表。但我希望它设置为将列表中的数据设置为两个不同的 textViews。我该怎么做。我已经解析了数据并得到正确的响应,但只想将数据拆分为两个文本视图
我的代码是
myList = new ArrayList<HashMap<String, Object>>();
mainListView = (ListView) findViewById(R.id.main_listview);
/*tv = (TextView) findViewById(R.id.result);
tv1 = (TextView) findViewById(R.id.result1);
tv2 = (TextView) findViewById(R.id.result2);*/
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("FilterCondition", "");
request.addProperty("UserID", -1);
request.addProperty("Type", "ALL");
request.addProperty("PageID", 1);
request.addProperty("SiteURL", "http://www.xxx.mobi/");
request.addProperty("SortCondition", "order by name");
request.addProperty("FilterID", -1);
request.addProperty("KeyValue", 1);
request.addProperty("EventFilterType", "");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
SoapObject result = null;
envelope.setOutputSoapObject(request);
AndroidHttpTransport sab = new AndroidHttpTransport(URL);
// Category C=new Category();
sab.debug = true;
try {
sab.call(SOAP_ACTION, envelope);
if (envelope.getResponse() != null) {
result = (SoapObject) envelope.bodyIn;
String[] values = new String[result.getPropertyCount()];
for (int i = 0; i < result.getPropertyCount(); i++) {
Log.d("Value", result.getProperty(i).toString());
int j = result.getPropertyCount();
Log.d("count is", Integer.toString(j));
// tv.setText("ss:" + result);
Log.d("status", result.toString());
}
list = new ArrayList<String>(
result.getPropertyCount());
String lv_arr[] = new String[result.getPropertyCount()];
for (int i1 = 0; i1 < 1; i1++) {
Object property = result.getProperty(i1);
if (property instanceof SoapObject)
{
SoapObject countryObj = (SoapObject) property;
SoapObject countryName = (SoapObject) countryObj
.getProperty("diffgram");
SoapObject country = (SoapObject) countryName
.getProperty("NewDataSet");
SoapObject ss = (SoapObject) country
.getProperty("Table");
Log.d("message", ss.getProperty("Name").toString());
list.add(ss.getProperty("Name").toString());
list.add(ss.getProperty("ShortDescription").toString());
list.add(ss.getProperty("IconPath").toString());
Log.d("list values", list.toString());
/*
* JSONObject o = new JSONObject(sr); JSONArray
* js=o.getJSONArray("Table"); for(int i4 = 0; i4 <
* js.length(); i4++){
*
* Log.d("log_tag","_id"+o.getInt("Name")+
* ", mall_name"+o.getString("ObjectID")+
* ", location"+o.getString("ComponentID"));
*/
/*tv.setText(list.get(0).toString());
tv1.setText(list.get(1).toString());
tv2.setText(list.get(2).toString());*/
}
else
{
Log.d("response", "null");
}
}
// addDataToList();
ArrayList fillMaps = new ArrayList();
for(int i = 0; i < 10; i++){
HashMap<String,Object > map1 = new HashMap<String,Object>();
map1.put("icon", R.drawable.ic_launcher);
map1.put("Course", list);
map1.put("Description", "");
fillMaps.add(map1);
}
SimpleAdapter aa = new SimpleAdapter(this, fillMaps, R.layout.row,
new String[] {"Course", "Description", "icon"},
new int[] {R.id.txt1, R.id.txt2, R.id.img1});
mainListView.setAdapter(aa);
}
}
catch (Exception e) {
e.printStackTrace();
}