title: ClassCastException in findViewById while using custom view
body: <p>I am using custom TextView. But when I am retrieving it using find view by Id I get ClassCastException. I have using it in XML file like this:</p>
  
  <p><code>&lt;View class="com.android.smsapp.MsgTextView" 
          android:id="@+id/text"</code></p>
  
  <p>And using it in java file like this.</p>
  
  <p><code>MsgTextView  text = (MsgTextView) row.findViewById(R.id.text);</code></p>
  
  <p>What am I doing wrong?</p>
  
  <hr>
  
  <p>@Pavandroid</p>
  
  <p>I have included it in correct file    </p>
  
  <pre><code>    package com.android.smsapp;
  
      import android.content.Context;
      import android.util.AttributeSet;
      import android.widget.TextView;
  
      public class MsgTextView extends TextView {
      private String sender;
  
      MsgTextView(Context c){
          super(c);
      }
  
      MsgTextView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      MsgTextView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      public void setSender(String s) {
          sender = s;
      }
  
      public String getSender() {
          return (sender);
      }
  }`
  </code></pre>
  
  <p>Also When I checked properly, LogCat is showing one more line </p>
  
  <pre><code>03-19 14:30:41.476: E/AndroidRuntime(24089): Caused by: java.lang.NoSuchMethodException: MsgTextView(Context,AttributeSet).. But I have defined this constructor. 
  </code></pre>