title: Sample code which extends View class and using layout xml file
body: <p>I am new to the Android world.... it will be a great help if someone correct me... what am I doing wrong the below code...</p>
  
  <ul>
  <li>Requirement : Need to create a custom View(using xml layout file) so that the same view should be used inside in my application activities. Here i go with the sample code which i am working on,</li>
  </ul>
  
  <p><strong>cutomviewxml.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Large Text"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Extended View class ...code...</p>
  
  <p><strong>mycustomTextview.java</strong></p>
  
  <pre><code>public class mycustomTextview extends View {
  
      private View mView;
      Context mycontext;
  
      public mycustomTextview(Context context, AttributeSet attrs) {
          super(context, attrs);
          // TODO Auto-generated constructor stub
  
      this.mycontext = context;
  
      LayoutInflater inflater;
      inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      mView = inflater.inflate(R.layout.cutomviewxml, null);
      }
  </code></pre>
  
  <p>Activity <strong>main.xml</strong> file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
  
       &lt;com.motorola.mycustomTextview
           android:id="@+id/customtextview"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_below="@+id/textView2"
           android:layout_marginLeft="143dp"
           android:layout_marginTop="69dp"
           android:layout_toRightOf="@+id/textView1" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Activity class <strong>sample.java</strong> ..</p>
  
  <pre><code>public class sample extends Activity{
  
      private static final String LOG_TAG = "sampleActivity";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Log.i(LOG_TAG,"OnCreate of sampleActivity");
          setContentView(R.layout.main);
  }
  }
  </code></pre>