How to cast TextView with my custom TextView?
<p>I take text view instance from here:</p>

<pre><code>    TextView date = null;

        try {
            date = (TextView) getLayoutInflater().inflate(
                    R.layout.some_textview, null);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();

        } 
</code></pre>

<p>I created my custom textview:</p>

<pre><code>public class MyTextView extends TextView{

    public MyTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public MyTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(Context context) {
        super(context);
    }


}
</code></pre>

<p>Now i want to cast those:</p>

<pre><code>MyTextView my = (MyTextView)date;
</code></pre>

<p>I get exeption for this one:</p>

<pre><code> java.lang.ClassCastException: android.widget.TextView cannot be cast to com.myapp.name.MyTextView
</code></pre>

<p>So how it should be done ?</p>

<p>Thanks.</p>

<p><em><strong>Edit:</em></strong></p>

<p>If i declare <code>date</code> as <code>MyTextView</code>, still get same exception, ther is my xml of some_textview:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="This is a template for date text view"  
        /&gt;
</code></pre>
