Two different layout xml in on Activity class
<p>I have two different layout xml in one Activity class.</p>

<pre><code>1)usertopiclist
2)topiclistitem
</code></pre>

<p>I am using usertopiclist.xml in oncreate method. I have some <code>imageview (id=remove)</code> in topiclistitem (My other layout) and i want onclick event on this imageView but i dont know how to get their id (I get nullpointer exception)
 plz help</p>

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



&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rootRL"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_y="0dp"
    android:background="@drawable/jpeg"
    android:orientation="vertical" &gt;

    &lt;Button
        android:id="@+id/update"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_margin="10dp"
        android:background="@drawable/rounded_button"
        android:text="Update"
        android:textColor="#333"
        android:textSize="16dp"
        android:textStyle="bold" /&gt;

    &lt;ListView
        android:id="@+id/mylist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/update"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/autocomplete"
        android:padding="5dp"
        android:textColor="#000"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/rounded_list" &gt;

    &lt;/ListView&gt;

    &lt;ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignRight="@+id/autocomplete"
        android:layout_marginTop="7dp"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="2dp"
        android:layout_marginBottom="7dp"
        android:src="@drawable/list" /&gt;

    &lt;TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_toLeftOf="@+id/imageView1"
        android:text="My Topic List" /&gt;

    &lt;com.example.postreply.CustomAutoCompleteTextView
        android:id="@+id/autocomplete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/imageView1"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/rounded_edittext"
        android:completionThreshold="1"
        android:drawableRight="@drawable/search"
        android:ems="10"
        android:hint="Search and Add Topics..."
        android:maxLines="1"
        android:padding="10dp"
        android:textSize="18sp" /&gt;

&lt;/RelativeLayout&gt;





 &lt;?xml version="1.0" encoding="utf-8"?&gt; (topiclistitem.xml)
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="4dip"
    android:background="@drawable/rounded_editlist"
    android:layout_margin="5dp" &gt;

    &lt;TextView
        android:id="@+id/topiccode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/code"
        android:text="test2"
        android:textSize="11sp" /&gt;

    &lt;ImageView
        android:id="@+id/remove"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/remove" /&gt;

&lt;/RelativeLayout&gt;

//-------------------------------------------

    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      setContentView(R.layout.usertopiclist);

//------------------------------------ (I am using this code but it does not work)

View inflatedView = getLayoutInflater().inflate(R.layout.topiclistitem, null);

  imageview = (ImageView) inflatedView.findViewById(R.id.remove);
  imageview.setOnClickListener(new View.OnClickListener() 
</code></pre>
