0

我在 android 中玩耍,现在我在列表视图中添加了评分栏,实际评分来自服务器响应,然后存储到 arraylist 中,然后应该使用 dataadapter 将其发送到列表视图。问题是我不知道如何通过给出的响应来增加运行时的评分栏,想法?这是我的代码:

/**
 * 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);
               }
          });

      }     
  }
4

1 回答 1

0

通过将值传递给方法 setRating() 可以轻松设置 RatingBar 值

RatingBar rb=(RatingBar)findViewById(R.id.ratingBar);
/*
*After you get response from server, assuming String serverResponse contains the value.
*/
rb.setRating(Float.parseFloat(serverResponse));
于 2012-12-23T19:07:51.327 回答