Android Change onClickListener in external method when implementing onClickListener?

You can just implement a flag inside the onClick method which will guard the methods executing inside onClick No need to set onClickListener to null just set flag to false and the onClick method will do nothing. Hope this helps.

You can just implement a flag inside the onClick method which will guard the methods executing inside onClick. No need to set onClickListener to null, just set flag to false and the onClick method will do nothing. Hope this helps.

Thanks for the answer – user848761 Nov 2 '11 at 9:03 Yaqub Ahmad posted a piece of code that does exactly that, in his answer – Guillaume Nov 2 '11 at 9:29.

Private Button myButton; @Override public void onCreate (Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Main); myButton = (Button) findViewById(R.id.

Mynewbutton); myButton. SetOnClickListener(/* your click listener here */); myButton. SetEnabled(false); } private void whateverFunction() { if(true) { myButton.

SetEnabled(true); } else { myButton. SetEnabled(false); } } This way you make it not respond to touches when it is disabled.

Private boolean enableClick; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Main); Button button1 = (Button) findViewById(R.id.

Button1); button1. SetOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(enableClick) { // do } } } ); } You just need to update the value of enableClick.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions