title: why this exception: java.lang.RuntimeException: Error inflating class
body: <p>I am trying to develop a tiny android app that just opens a browser to a website. I am using mac OS 10.6 and the latest android/eclipse tools.  But I keep getting this exception:</p>
  
  <blockquote>
    <p>11-29 13:03:55.113: E/AndroidRuntime(1012): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycomp/com.mycomp.pack}: android.view.InflateException: Binary XML file line #7: Error inflating class com.mycomp.MyTextView</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>package com.mycomp;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.net.Uri;
  import android.os.Bundle;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.View;
  import android.widget.TextView;
  
  
  public class myapp extends Activity {
  /** Called when the activity is first created. */`
  
  private MyTextView myview;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);      
      Log.d("onCreate", "onCreate ");   
  
      myview  = (MyTextView)findViewById(R.id.myview);
      myview.setParent(this);
  }
  
  
  
  
  public static   class MyTextView extends TextView {
      private View mLastVisChangedView;
      private int mLastChangedVisibility;
      private Activity parent;
  
      public void setParent(Activity p){
          parent =p;
  
      }
      public MyTextView(Context context) {
          super(context);
      }
  
      public MyTextView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public MyTextView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      public View getLastVisChangedView() {
          return mLastVisChangedView;
      }
  
      public int getLastChangedVisibility() {
          return mLastChangedVisibility;
      }
  
      @Override
      protected void  onVisibilityChanged(View changedView, int visibility){
          Log.d("onVisibilityChanged", "new vis == " + visibility);
          if (parent !=null &amp;&amp; visibility == View.VISIBLE){
              parent.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mysite.com")));
              parent.moveTaskToBack(true);
          }
      }
  }
  
  }
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" &gt;
  
  &lt;com.mycomp.MyTextView
       android:id="@+id/myview"
        android:text="@string/hello"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>