Button action inside list view
<p>I have a list view with a custom adapter. the layout for the adapter has some ImageViews
which act as buttons. I implemented the onclicklistner for these</p>

<pre><code>listView.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1,int arg2, long arg3) {

        ImageView btn = (ImageView) arg1.findViewById(R.id.btn);
        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
            // TODO Auto-generated method stub
            // for the  button action
            Log.d("Button Action", "Clicked");
            }
        });

    }


}
</code></pre>

<p>when i click the button first time it does not do any thing .i have to click twice to
get the button work. Why is this. can any one point me my mistake </p>

<p>thanks in advance</p>
