2012-11-10 46 views
0

我在android中玩耍,現在我添加評級欄到列表視圖,酒吧實際評級來自服務器resposnse然後存儲到一個arraylist然後應該使用dataadapter將其發送到列表視圖。問題是我不知道如何通過給出的響應在運行時膨脹評級欄,想法? 繼承人我的代碼:我如何設置RatingBar在服務器響應列表視圖

/** 
* After completing background task Dismiss the progress dialog 
* **/ 

protected void onPostExecute(String file_url) { 
    // dismiss the dialog after getting all score 
    pDialog.dismiss(); 
    // updating UI from Background Thread 
    runOnUiThread(new Runnable() { 
     public void run() { 

      /** 
      * Updating parsed JSON data into ListView 
      * */ 

      ListAdapter adapter = new SimpleAdapter( 
       BusinessActivity.this, businessArrayList, 
       R.layout.business_list_item, new String[] { TAG_NAME, TAG_EMAIL, TAG_SCORE }, 
       new int[] { R.id.player_name, R.id.player_email, R.id.player_rating }); 

       // updating listview 
       setListAdapter(adapter); 
       } 
      }); 

     }  
    } 

回答

0

的RatingBar值可以由值傳遞給方法setRating()

RatingBar rb=(RatingBar)findViewById(R.id.ratingBar); 
/* 
*After you get response from server, assuming String serverResponse contains the value. 
*/ 
rb.setRating(Float.parseFloat(serverResponse)); 
+0

setrating在我的情況下沒有影響可以容易地設定 –

相關問題