I am creating a dynamically buttons when one button is clicked. i.e. under onClick event of that button. But it is creating n number of button dynamically for every click one button is created.
LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayout1);
.....
public void onClick(View arg0) {
Button topArtistbutton = new Button(SalesPanel.this, null,android.R.attr.buttonStyleSmall);
topArtistbutton.setText("Top Artist");
topArtistbutton.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));topArtistbutton.setId(3);
ll.addView(topArtistbutton);
}
i want only one button created dynamically