2011-09-13 145 views
-3

成功連接到服務器(我的本地主機)後,我想檢索服務器發送給我的數據。任何人都可以請建議我該怎麼做? 收到這些數據後,我必須將它存儲到一個數組中,然後必須將它一個一個地讀取到下拉列表中。如何從服務器檢索數據

感謝

+0

獲取數據從服務器通常通過http請求完成 – slayton

+0

我知道我的問題很愚蠢,但讓我告訴你所有這些,我剛剛兩週前開始使用Android。我甚至沒有它的基本知識,這是我的學習階段。 –

+0

謝謝Slayton,但我已收到來自服務器的響應,現在只需要檢索數組中的數據。而不是必須從該數組中獲取數據n將其放置在我的Spinner對象 –

回答

0

希塔爾我還沒有與服務器的任何應用程序的工作,但我在當地獲取的數據,然後把它放在一個數組和微調顯示,這可能會幫助ü

Cursor c = db.fetchAllReminders(); 
      startManagingCursor(c); 

      // Create an array to specify the fields we want (only the TITLE) 
      String[] from = new String[]{DataManager.NAME}; 
      // and an array of the fields we want to bind in the view 
      int[] to=new int[] { android.R.id.text1 }; 
//   to[0]=android.R.id.text1; 

      final Spinner spinner = (Spinner) this.findViewById(R.id.spins); 


      // Now create a simple cursor adapter and set it to display 
      final SimpleCursorAdapter reminders =new SimpleCursorAdapter(this, 
        android.R.layout.simple_spinner_item, c, from, to); 
      spinner.setAdapter(reminders); 
相關問題