2012-06-23 82 views
0

我有四個單選按鈕,我要爲每一個文本,我從服務器獲取數據和數據集,以像這樣的按鈕:的Android組單選按鈕文本

protected String[] doInBackground(String... params) { 
HttpClient client = new DefaultHttpClient(); 
       website = new URI(
         "http://10.0.2.2:8080/LocalizedBasedComptitionServer/SendQuestion"); 
       HttpPost request = new HttpPost(); 
       request.setURI(website); 
       HttpResponse response = client.execute(request); 
       HttpEntity entity = response.getEntity(); 
       results[0] = response.getFirstHeader("Info").toString(); 
       results[1] = response.getFirstHeader("Question").toString(); 
       results[2] = response.getFirstHeader("Choice1").toString(); 
       results[3] = response.getFirstHeader("Choice2").toString(); 
       results[4] = response.getFirstHeader("Choice3").toString(); 
       results[5] = response.getFirstHeader("Choice4").toString(); 
       results[6] = response.getFirstHeader("Hint1").toString(); 

    results[7] = response.getFirstHeader("Hint2").toString(); 
} 
protected void onPostExecute(String[] results) { 
      super.onPostExecute(results); 
      question.setText(results[1]); 
      choice1.setText(results[2]); 
      choice2.setText(results[3]); 
      choice3.setText(results[4]); 
      choice4.setText(results[5]); 
      firstHint.setText(results[6]); 
      secondHint.setText(results[7]); 
      // rightChoice = Integer.parseInt(results[8]); 
     } 

但我問題是,如果我發送羅姆,米蘭,意大利,愛到客戶端,數據打印到廣播buttoms是選擇1:羅姆的選擇2:米蘭,choice3:意大利,choice4:愛 我不想打印該選擇1,choice2, choice3,choice4 我在做什麼錯,謝謝

回答

2

嘗試response.getFirstHeader("xxx").getValue()

+0

我會嘗試,但我發送它之前打印服務器上的數據,它是正確的,無論如何,我會嘗試 – Totti

+0

getFirstHeader返回一個[頭](http://developer.android.com/reference/org/apache/ http/Header.html)對象,它有一個名稱和一個值。可能toString()返回一個包含它們的字符串。 – ekholm

+0

謝謝你,它的作品 – Totti