android.view.InflateException: Binary XML file line when using custom view
<p>The exception:</p>

<pre><code>&gt;         10-13 11:47:32.151: E/AndroidRuntime(618): FATAL EXCEPTION: main
&gt; 
&gt;     10-13 11:47:32.151: E/AndroidRuntime(618): android.view.InflateException: Binary XML file line #3: Error
&gt; inflating class com.example.demo.ToDoListView 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.view.LayoutInflater.createView(LayoutInflater.java:596) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.view.LayoutInflater.inflate(LayoutInflater.java:466) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.LayoutInflater.inflate(LayoutInflater.java:396) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.widget.AbsListView.obtainView(AbsListView.java:2267) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.ListView.onMeasure(ListView.java:1156) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.View.measure(View.java:15172) 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.View.measure(View.java:15172) 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.View.measure(View.java:15172) 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.widget.RelativeLayout.measureChild(RelativeLayout.java:602)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.RelativeLayout.onMeasure(RelativeLayout.java:415) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.View.measure(View.java:15172) 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
&gt; 10-13 11:47:32.151: E/AndroidRuntime(618):    at
&gt; android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 10-13
&gt; 11:47:32.151: E/AndroidRuntime(618):  at
&gt; android.view.View.measure(View.java:15172) 10-13 11:47:32.151:
&gt; E/AndroidRuntime(618):    at
&gt; android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
</code></pre>

<p>This is my xml. It show no errors.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;com.example.demo.ToDoListView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dp"
  android:scrollbars="vertical"
  android:textColor="@color/notepad_text"
  android:fadingEdge="vertical"
/&gt; 
</code></pre>

<p>I am trying to use it with a list adapter:</p>

<pre><code>        aa=new ArrayAdapter&lt;String&gt;(this, R.layout.todolist_item,todoItems);
</code></pre>

<p>To Do list class:</p>

<pre><code>public class ToDoListView extends TextView{
    private Paint marginPaint;
    private Paint linePaint;
    private int paperColor;
    private float margin;

    public ToDoListView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    public ToDoListView(Context context, AttributeSet st, int ds) {
        super(context);
        init();
    }

    private void init() {
      Resources myResources=getResources();
      marginPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
      marginPaint.setColor(myResources.getColor(R.color.notepad_margin));
      linePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
      linePaint.setColor(myResources.getColor(R.color.notepad_lines));
      paperColor=myResources.getColor(R.color.notepad_paper);
      margin=myResources.getDimension(R.dimen.notepad_margin);      
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(paperColor);
        canvas.drawLine(0, 0, 0, getMeasuredHeight(), linePaint);
        canvas.drawLine(0, getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight(), linePaint);
        canvas.drawLine(margin, 0, margin, getMeasuredHeight(), marginPaint);
        canvas.save();
        canvas.translate(margin, 0);
        super.onDraw(canvas);
        canvas.restore();
    }



}
</code></pre>
