rakesh:
I want to show 2 Toast in different rating.When user click on submit Button,It show toast msg. If it is 5 Star show Toast "msg1". If less than 5 stars, change Toast "msg2".
Here is my code.
dialogView.findViewById(R.id.review_rating).setOnTouchListener
(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
float touchPositionX = event.getX();
float width = review_rating.getWidth();
float starsf = (touchPositionX / width) * 5.0f;
int stars = (int) starsf + 1;
if (stars > 5) {
stars = 5;
}
rating_stars = stars + "";
review_rating.setRating(stars);
Toast.makeText(DetailActivity.this, stars + " rate", Toast.LENGTH_SHORT).show();
v.setPressed(false);
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.setPressed(true);
}
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
v.setPressed(false);
}
return true;
}
});
dialogBuilder.setNegativeButton("Cancel", null);
dialogBuilder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}
);
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE