Help with getParent() downcast
<p>I'm learning android/java and have this example code I can't get to work:</p>

<pre><code>OnRatingBarChangeListener l = new OnRatingBarChangeListener() {
 public void onRatingChanged(RatingBar ratingBar, float rating,
   boolean fromTouch) {
  Integer myPos=(Integer)ratingBar.getTag();
  RowModel model=getModel(myPos);
  model.rating = rating;

  LinearLayout p=(LinearLayout)ratingBar.getParent();
  TextView l=(TextView)p.findViewById(R.id.label);
  l.setText(model.toString());
 }
};
</code></pre>

<p>Everything works except the LinearLayout / getParent() downcast. At runtime it creates a ClassCastException. If I comment out that block of code then everthing works fine. What am I missing?</p>
