13 Stimmen

wie man den RatingBar-Wert erhält

Wie man den Wert der Bewertungsleiste liest und anzeigt

i[0] // should be selected value

private OnClickListener onclickbutton1 = new OnClickListener() {
    public void onClick(View v) {
        int[] i = new int[]{ R.id.mRatingBar};

        statusMessage.setText("value is " + i[0]);
    }
};

// das funktioniert

private OnClickListener onclickbutton1 = new OnClickListener() {
    public void onClick(View v) {
        RatingBar mBar = (RatingBar) findViewById(R.id.mRatingBar);

        float[] i = new float[]{ mBar.getRating() };

        statusMessage.setText("value is.. " + i[0]);
    }
};

0voto

sachin shejekar Punkte 21
RatingBar rate = (RatingBar)findViewById(R.id.R_rate);

//use ratings within event listner code block

float rating = rate.getRating();

0voto

Steve Punkte 9577
import android.widget.RatingBar;

public class PageAboutFragment extends Fragment implements RatingBar.OnRatingBarChangeListener  {

rbSearch.setOnRatingBarChangeListener(this);

public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
        tvRatingContent.setText(rating+"/5 Stars");
}

0voto

Uzzal Mondal Punkte 1
var ratingBar = findViewById<RatingBar>(R.id.ratingBarid);
var text1 = findViewById<TextView>(R.id.textViewid)

// rating bar click to show the text view

ratingBar.setOnRatingBarChangeListener(object: RatingBar.OnRatingBarChangeListener{

    override fun onRatingChanged(ratingBar: RatingBar?, rating: Float, fromUser: Boolean) {
       // TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        text1.text = "Rating bar result $rating"
    }
})

0voto

Uzzal Mondal Punkte 1
    var ratingBar = findViewById<RatingBar>(R.id.ratingBarid);
    var btn= findViewById<Button>(R.id.buttonid);
    var text1 = findViewById<TextView>(R.id.textViewid)

    /*

     3rd rules of

    if (ratingBar!=null){

        btn.setOnClickListener {

            val msg = ratingBar.rating.toString();
            text1.setText("The result of $msg")
        }
    }

   // rating bar click to show the text view

   // ratingBar.setOnRatingBarChangeListener(this)

              // 1st rules of Rating Bar..
  ratingBar.setOnRatingBarChangeListener(object: RatingBar.OnRatingBarChangeListener{

      override fun onRatingChanged(ratingBar: RatingBar?, rating: Float, fromUser: Boolean) {
         // TODO("not implemented") //To change body of created functions use File | Settings | File Templates.

          text1.text = "Rating bar result $rating"
      }
  })

}

            // 2nd rules of Rating bar ....
override fun onRatingChanged(ratingBar: RatingBar?, rating: Float, fromUser: Boolean) {
    //TODO("not implemented") //To change body of created functions use File | Settings | File Templates.

    var text1 = findViewById<TextView>(R.id.textViewid)
    text1.text = "Rating Bar Result : $rating"

    */
}

CodeJaeger.com

CodeJaeger ist eine Gemeinschaft für Programmierer, die täglich Hilfe erhalten..
Wir haben viele Inhalte, und Sie können auch Ihre eigenen Fragen stellen oder die Fragen anderer Leute lösen.

Powered by:

X