private void load_view(final String result) { JSONObject json = AppSettings.getSuccessJSON(result, this); if (json == null) return; try { /* _total_stars = json.getInt("total_star"); _total_voters = json.getInt("total_voters"); _avg_star = (float) json.getDouble("avg_star"); */ ((TextView) findViewById(R.id.txt_avg_star)).setText(json.getString("avg_star")); ((TextView) findViewById(R.id.txt_total_voter)).setText(json.getString("total_voters")); RatingBar bar = (RatingBar) findViewById(R.id.rating_bar); bar.setRating(json.getInt("avg_star_num")); JSONArray list = json.getJSONArray("list"); Intent intent = new Intent(); intent.putExtra("star", json.getString("avg_star")); intent.putExtra("star_num", json.getInt("avg_star_num")); intent.putExtra("star_voternum", json.getString("total_voters")); this.setResult(RESULT_OK, intent); JSONObject stars_info = json.getJSONObject("stars_info"); JSONObject star = stars_info.getJSONObject("1"); ProgressBar pb = (ProgressBar) findViewById(R.id.pb_star1); TextView txt = (TextView) findViewById(R.id.txt_star1_voter); pb.setProgress((int) (star.getDouble("percent") * 100)); txt.setText(star.getString("count")); // star 2 star = stars_info.getJSONObject("2"); pb = (ProgressBar) findViewById(R.id.pb_star2); txt = (TextView) findViewById(R.id.txt_star2_voter); pb.setProgress((int) (star.getDouble("percent") * 100)); txt.setText(star.getString("count")); star = stars_info.getJSONObject("3"); pb = (ProgressBar) findViewById(R.id.pb_star3); txt = (TextView) findViewById(R.id.txt_star3_voter); pb.setProgress((int) (star.getDouble("percent") * 100)); txt.setText(star.getString("count")); star = stars_info.getJSONObject("4"); pb = (ProgressBar) findViewById(R.id.pb_star4); txt = (TextView) findViewById(R.id.txt_star4_voter); pb.setProgress((int) (star.getDouble("percent") * 100)); txt.setText(star.getString("count")); star = stars_info.getJSONObject("5"); pb = (ProgressBar) findViewById(R.id.pb_star5); txt = (TextView) findViewById(R.id.txt_star5_voter); pb.setProgress((int) (star.getDouble("percent") * 100)); txt.setText(star.getString("count")); _comments = new ArrayList<Comment>(); for (int i = 0; i < list.length(); i++) { JSONObject item = list.getJSONObject(i); Comment comment = new Comment(); comment.comment = item.getString("comment"); comment.user_id = item.getInt("user_id"); comment.star = item.getInt("star"); comment.submit_time = item.getString("submit_time"); comment.username = item.getString("username"); _comments.add(comment); } if (_comments.size() == 0) { Comment comment = new Comment(); comment.comment = "目前还没有评论"; comment.user_id = 0; comment.star = 5; comment.submit_time = "2013-10-1"; comment.username = "******"; _comments.add(comment); } ListView lv = (ListView) findViewById(R.id.lv_items); CommentAdapter adapter = new CommentAdapter(this); lv.setAdapter(adapter); } catch (Exception e) { log(e); } }