title: Android including an xml layout to activity
body: <p>I've an <code>activity.java</code> file in which my <code>setContentView(R.layout.x);</code> Now,I've an <code>y.xml</code> in which I've an <code>Linear Layout</code>,I've to attach an <code>onclick()</code> method to my view.
  Attaching <code>onclick()</code> has to be in my <code>activity.java</code> file, How do I include <code>y.xml</code>.</p>
  
  <p>I tried this,</p>
  
  <pre><code>1.     layout = (LinearLayout) findViewById(R.layout.y);
         eView = (EditText)layout. findViewById(R.id.editview);
  
  2.      eView = (EditText)findViewById(R.id.editview); 
  </code></pre>
  
  <p>but both gives my <code>null pointer exception</code>, How do I include my <code>editText</code></p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>final LayoutInflater lyInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          showLinearLayout = (LinearLayout) lyInflater.inflate(R.layout.y, null);
           showView = (EditView) showLinearLayout.findViewById(R.id.edittext);
  </code></pre>