Android GridView MultipleView custom layout with specific functions for each view
<p>I'm very sorry for the long post, can you please help.</p>

<p>I am new to android development and I have this activity in which it has a GridView with a custom layout :
`</p>

<pre><code>&lt;FrameLayout 
    android:layout_width="90dp"
        android:layout_height="70dp"
        android:maxHeight="100dp"
        android:maxWidth="100dp" &gt;
    &lt;ImageView
        android:id="@+id/Backgnd"
        android:layout_width="90dip"
        android:layout_height="75dip"
        android:maxHeight="100dp"
        android:maxWidth="100dp"
        android:scaleType="fitXY"
        android:src="@drawable/bckgnd" /&gt;
    &lt;ImageView
        android:id="@+id/SavedImage"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_gravity="center"
         /&gt;
</code></pre>

<p></p>

<pre><code>&lt;ImageView
    android:id="@+id/Delete"
    android:layout_width="22dp"
    android:layout_height="21dp"
    android:src="@drawable/x" /&gt;
</code></pre>

<p>`</p>

<p>The imageViews in the FrameLayout has a different function from that outside the layout.</p>

<p>I am using the OnItemClickListener() function of the gridview to set what each Image would do:`  public void onItemClick(AdapterView parent, View arg1, final int pos, long id) {</p>

<pre><code>    //setting the delete image function
    ImageView delete = (ImageView) arg1.findViewById(R.id.Delete);
    delete.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            Intent i = new Intent(GalleryActivity.this, VideoFrames.class);
            i.putExtra("ToShareFilePath", storedImageFolders.get(pos).toString()); // sending the folder path in the intent
            i.putExtra("DeletePrompt", true); // sending if the user clicked on the delete icon or not
            finish();
            startActivity(i);
            overridePendingTransition(0,0);
        }
    });
    //setting the folder cover Image function
    ImageView Folder = (ImageView) arg1.findViewById(R.id.SavedImage);
    Folder.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {

            Intent i = new Intent(GalleryActivity.this, VideoFrames.class);
            i.putExtra("ToShareFilePath", storedImageFolders.get(pos).toString()); // sending the folder path in the intent
            i.putExtra("DeletePrompt", false);// sending if the user clicked on the delete icon or not
            finish();
            startActivity(i);
            overridePendingTransition(0,0);
        }
    });
    //setting the backGround Image Function
    ImageView Folderbckgnd = (ImageView) arg1.findViewById(R.id.Backgnd);
    Folderbckgnd.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {

            Intent i = new Intent(GalleryActivity.this, VideoFrames.class);
            i.putExtra("ToShareFilePath", storedImageFolders.get(pos).toString());// sending the folder path in the intent
            finish();
            startActivity(i);
            overridePendingTransition(0,0);
        }
    });

}
</code></pre>

<p>}`</p>

<p>The problem is that the onclicklistener() function of each image is not executed except after clicking twice on the grid item. The first click to step intp the onItemClickListener function and the second one for each image's listener.(Sure I need it to operate from the first click)
I have tried using ontouchlistener for the images instead of the clicklistener but didn't  work. Also tried checking if the imageViews are pressed or not and depending on the pressed view it executes its code but also didnt detect that it was pressed. And at last , I tried isFocused() but in vain. </p>

<p>I'm very sorry for the long post, can you please help.</p>
