setting up an annonymous onclicklistener

satya - Tuesday, August 16, 2011 9:42:26 AM

here is the syntax


private void setupNewWordButtion(Button b)
    {
    	b.setOnClickListener(new OnClickListener()
    	{
    		@Override
    		public void onClick(View v)
    		{
    			createNewword();
    		}
    	});
    }

satya - Tuesday, August 16, 2011 9:47:10 AM

Annonymous classes have access to the parent classes methods

This will save you from the parent class from inheriting from an onclick listener and also having the need to create a switch statement as to which button is clicked.