Create Rating Bar in Dialog in Sketchware
//1st ASD Block:
final AlertDialog cpDialog = new AlertDialog.Builder(MainActivity.this).create();
View convertView = (View) getLayoutInflater().inflate(R.layout.color_picker_layout, null);
cpDialog.setView(convertView);
cpDialog.show();
//2nd ASD Block:
final Button rate = (Button)convertView.findViewById(R.id.button1);
rate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View a) {
//your blocks here
//3rd ASD Block:
cpDialog.dismiss();
}
});
//4th ASD Block:
final Button cancel = (Button)convertView.findViewById(R.id.button2);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View a) {
//Your Blocks here
//5th ASD Block:
cpDialog.dismiss();
}
});
//6th ASD Block:
final LinearLayout colorLayout = (LinearLayout)
convertView.findViewById(R.id.linear2);
//7th ASD Block:
rb = new RatingBar(this); rb.setNumStars(5); rb.setStepSize(0.5f); rb.setRating(0.0f); colorLayout.addView(rb); rb.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){ @Override public void onRatingChanged(RatingBar rating, float r,boolean user){
doy = rb.getRating();
} }); }
//8th ASD Block:
RatingBar rb; private void nothing() {
Then put this MoreBlock onClick Event of the button.
Comments
Post a Comment