I am not sure but assuming you have taken RatingBar in your addrate_layout
layout.
If its the case then you have to find RatingBar from the inflated layout.
For exmaple:
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mInflater.inflate(R.layout.addrate_layout, null);
addListenerOnRatingBar(view);
Modified method by passing View
:
public void addListenerOnRatingBar(View view) {
RatingBar ratingBar = (RatingBar) view.findViewById(R.id.beerRatingBar);
//if rating value is changed,
//display the current rating value in the result (textview) automatically
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
//next async task to update online database
}
});
}