I don't know why it happens, but as workaround you can declare your RatingBar in layout and inflate it before adding:
<RatingBar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/foodRatingBar" />
RatingBar c = (RatingBar) iflater.inflate(R.layout.rating_bar, row, false);