[android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Jaswant
It's simple: call setonClickListener() method for each button u'hv created. and in onClick() method u can find clicked button by checking its text eg: void onClick(View v) { MyCustButton btn=(MyCustButton )v; if(btn.getText().toString().equals(blabla)) } --

[android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Rockline
Hi, Thanks for your answer. However, this implies that I'll have to declare setOnClickListener for each button in my Activity object (in the constructor): Button MyButton1 = (Button)findViewById(R.id.MyButton1); generate_button.setOnClickListener(new Button.OnClickListener() {

[android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Jaswant
y u r creating new onClickListener every tym??? just implement OnClickListener explicitaly once and do whatever u want in onClick() method. like: public class MyActivity extends Activity implements OnClickListener { void onCreate(.) {

[android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Rockline
That's exactly what I needed. Sorry for the inconvenience. Thanks a lot. On Jul 5, 11:24 am, Jaswant jaswant1...@gmail.com wrote: y u r creating new onClickListener every tym??? just implement OnClickListener explicitaly once and do whatever u want in onClick() method. like: public

Re: [android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Ravi Sharma
other way is what jaswant has suggested, but i wouldnt use it. not object oriented...i persoanlly dont like functions which has too many ifs then elses, in your case it may go upto 100 also if your requirment is just changing a label...then i would say do somethin glike this Class MyButton

Re: [android-developers] Re: Which button is clicked in my activity

2011-07-05 Thread Ravi Sharma
oopsi and forgot to write...in constructor make sure you assign that fucntion as setOnCLickListener this.setOnCLickListener(this) public MyButton (){ this.setOnCLickListener(this) } public MyButton (TextView tv){ this.textView = tv; this.setOnCLickListener(this) } On Tue, Jul 5, 2011 at 11:20