Android layout file
<p>fI have created two layout files. First one is main.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    &gt;
    &lt;LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
        &lt;ImageButton android:src="@drawable/add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/addBtn" &gt;&lt;/ImageButton&gt;
        &lt;ImageButton android:src="@drawable/remove" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/remBtn"&gt;&lt;/ImageButton&gt;
    &lt;/LinearLayout&gt;  
    &lt;ListView android:layout_height="wrap_content" android:id="@+id/myListView" android:layout_width="match_parent" 
    android:background="#676767"  &gt;

    &lt;/ListView&gt;    
    &lt;Button android:text="Add" android:id="@+id/dialogAddBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;&lt;/Button&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>and the second one is dialog.xml  :</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;EditText android:id="@+id/dialogEditText" android:text="Enter Your Text Here" android:layout_height="wrap_content" android:layout_width="match_parent"&gt;&lt;/EditText&gt;
    &lt;DatePicker android:id="@+id/datPicker" android:layout_height="wrap_content" android:layout_width="match_parent" &gt;&lt;/DatePicker&gt;
    &lt;LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
     &lt;Button android:text="Add" android:id="@+id/dialogAddBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;&lt;/Button&gt;
     &lt;Button android:text="Cancel" android:id="@+id/dialogCancelBtn" android:layout_width="200px" android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;&lt;/Button&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>If u look closely than u will find that "dialogAddbtn" is in both layouts. Now , How can i distinguish those buttons in java coding. Becoz both buttons have same id.</p>
