コード例 #1
0
  /** 初始化 */
  public void setupViews() {

    intent = getIntent();
    mAppId = intent.getIntExtra("app_id", 0); // 获取对应app 的ID
    mAmount = intent.getIntExtra("amount", 0); // 评论人数
    mUserID = intent.getStringExtra("user_id"); // 用户id
    mHaveBeenEvaluated = intent.getBooleanExtra("isScore", false); // 获取是否评分
    mScoreValue = intent.getFloatExtra("ScoreValue", 0); // 获取已评分数
    if ("-1".equals(mUserID)) { // 祥情里没获取userid,则默认此时已评价(不提交评分信息)
      mHaveBeenEvaluated = true;
    }
    mRatingBar = (RatingBar) findViewById(R.id.ratingBar);
    bar = (LinearLayout) findViewById(R.id.bar);
    mRatingBarText = (TextView) findViewById(R.id.text);
    animationDrawable = (AnimationDrawable) bar.getBackground();
    mCloseButton = (ImageButton) findViewById(R.id.close);
    mTextView1 = (TextView) findViewById(R.id.text_1); // 已有多少人评价
    mTextView2 = (TextView) findViewById(R.id.text_2); // 使用说明

    mRatingBar.setRating(mScoreValue);
    mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());

    //		if(mHaveBeenEvaluated){ //已评价
    //			evaluated();
    //			//mRatingBar.setFocusable(false);//让星星失去焦点
    //			AppLog.d(TAG,"-------------------------id--"+mAppId +"--已评价----------------");
    //		}else{
    //			mRatingBar.setRating(mScoreValue);
    //			mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());
    //			AppLog.d(TAG,"-------------------------id--"+mAppId +"--未评价----------------");
    //		}

    // 每次都让评价
    // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());

    mCloseButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (v.getId() == R.id.close) {
              finish();
            }
          }
        });
    setCloseFocuseChange(mCloseButton);
    mRatingBar.requestFocus();
    animationDrawable.start();
    mRatingBar.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            mIsSuer = true;
            mTextView1.setText(
                AppAppraisalActivity.this.getString(R.string.app_appraisal_text1, mAmount + 1));
            handler.sendEmptyMessageDelayed(CLOSE, 700);
          }
        });
    setBarFocuseChange(mRatingBar);
  }
コード例 #2
0
    public OrderItemViewHolder(View itemView, IOrderItemViewHolderClicks listener) {
      super(itemView);
      mListener = listener;

      orderCardView = (CardView) itemView.findViewById(R.id.orderCard);

      quantityView = (TextView) itemView.findViewById(R.id.orderItemCard_quantity);
      nameView = (TextView) itemView.findViewById(R.id.orderItemCard_name);
      priceView = (TextView) itemView.findViewById(R.id.orderItemCard_price);
      imageView = (ImageView) itemView.findViewById(R.id.orderItemCard_image);
      ratingBar = (RatingBar) itemView.findViewById(R.id.orderItemCard_ratingBar);
      commentButton = (Button) itemView.findViewById(R.id.orderItemCard_commentButton);

      commentButton.setOnClickListener(this);
      ratingBar.setOnClickListener(this);
    }