How to create multiple buttons at runtime? + android
<p>I wrote the following code but am not getting how to write OnclickListner() method for all buttons.</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        LinearLayout layout = (LinearLayout) findViewById(R.id.ll1Relative);
        for (int i = 1; i &lt; 10; i++) {

            LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(

                    LinearLayout.LayoutParams.WRAP_CONTENT,
                   LinearLayout.LayoutParams.WRAP_CONTENT
            );




            Button b = new Button(this);
            b.setText(""+ i);
            b.setId(100+i);
           b.setWidth(30);
           b.setHeight(20);




            layout.addView(b, p);
        }

        }
</code></pre>
