我正在Android中玩游戏,现在我在列表视图中添加了评级栏,条形码实际评级来自服务器resposnse,然后存储到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);
}
});
}
}
答案 0 :(得分: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));