设置对listView的响应

时间:2012-04-17 09:12:25

标签: android listview response

我收到了来自服务器的响应,我已经存储在列表中。我正在获取整个数据列表。但我希望它设置为将列表中的数据设置为两个不同的textViews.How我可以这样做。我已经解析了数据并获得了正确的响应,但只想将数据拆分为两个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();
            }

1 个答案:

答案 0 :(得分:0)

您需要自定义listView吗? (意味着你想每行显示2个文本框?)