2012-04-17 12 views
0

リストに格納されているサーバからの応答があります。私はdatainリスト全体を取得しています。リストから2つの異なるtextViewにデータを設定したいと思います。 this.Iはすでにデータを解析し、適切な応答を得たが、わずか2 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(); 
      } 

答えて

0

は、カスタマイズされたリストビューが必要ですのですか? (1行に2つのテキストボックスを表示することを意味しますか?)

+0

私は左側に1つのイメージを持ち、右側にはテキストと2つのテキストボックスを持っています。右側には、私は応答を得ています。 2つのtextViews – user1196969

+0

あなたは独自のアダプタを実装し、必要に応じてtextViewsとimageを含むxml行レイアウトを実装する必要があります。このシンプルな[example](http://www.sohailaziz.com/2012/04/custom-adapter-for-listview-android.html)を試してみてください。 – SohailAziz

関連する問題