Android: runtime OnClickListener does not work
<p>I'm developing an app for Android devices using Eclipse and Android SDK;
I would like to add some ImageButtons (at runtime) with the same OnClickListener. The problem is that the OnClickListener works ONLY for the first added button. 
For all the next buttons the onClick event simply doesn't fire.</p>

<p>Have someone already encountered (and solved) this problem?</p>

<pre><code>public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
    ImageButton myButton= new ImageButton(this);
    myButton.setMaxHeight(140);
    myButton.setMaxWidth(140);    
    myButton.setPadding(0, 0, 0, 0);
    myButton.setAdjustViewBounds(true);
    myButton.setImageResource(resId);

    myButton.setOnClickListener(new View.OnClickListener() {            
        public void onClick(View v) {

            // TODO Auto-generated method stub   

        }
    });

    myRelativeLayout.addView(myButton, 0);
}
</code></pre>
