How to highlight only one button in android
<p>In my project based on database values,i am dynamically creating buttons.Now here by pressing one button,i am highlighting that button.suppose if i press another button then this button will be highlighted, and first pressed button will be unhighlighted.</p>

<p>My question is: always pressed button will be highlighted until another button is pressed.</p>

<pre><code>    for (int i = 0; i &lt; arr.length; i++) {

        final Button b = new Button(this);          
        b.setWidth(80);
        b.setId(i + 1);         
        b.setText("M" + arr[i]);            
        ll.addView(b);      

        b.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                  b.setBackgroundColor(R.drawable.buttonbtn);

                  String str = b.getText().toString().substring(1);
                  Constant.diametervalue = str;
                  f1 = l.indexOf(Constant.diametervalue);
                  f2 = l.size();Log.e("","f1 value--"+f2);
                  Constant.length = f2;
                  InnerList adapter11 = new InnerList(this, str); 
                  adapter11.getCount();
                  gallery.setAdapter(adapter11);    
        }
    }
</code></pre>

<p>With my code by pressing one button it's highlighted.later if i press second button first and second buttons are highlighted.</p>
