Find array position using Button onclick in android
<p>my array</p>

<pre><code>String array1[] = menuname.toArray(new String[menuname.size()]);
array2 = menuid.toArray(new String[menuid.size()]);
</code></pre>

<p>my dynamic button coding</p>

<pre><code>LinearLayout linearLayout = (LinearLayout) findViewById(R.id.l);
        List&lt;Button&gt; list = new ArrayList&lt;Button&gt;();
        for (int i = 1; i &lt; array1.length; i++) {
            LinearLayout l = new LinearLayout(this);
            l.setOrientation(LinearLayout.HORIZONTAL);


            button.setText(String.valueOf(i));
            button.setText(" " + array1[i]);
            button.setId(i);
            button.setWidth(180);
            button.setHeight(60);

            button.setTextColor(Color.BLUE);
            button.setTypeface(Typeface.SERIF, Typeface.BOLD);
            l.addView(button);
            linearLayout.addView(l);// if you want you can layout params
                                    // linearlayout
            list.add(button);

        }
</code></pre>

<p><code>array1[]</code> contains the names of the <code>button</code>...and <code>array2[]</code> contains id of the button ....i want to set id and name for the dynamic button..how to do this?</p>
