Question

I have a FrameLayout defined in xml with:

android:onClick="cancel"

The activity that creates the ActionBar has a method that looks like:

public void cancel ( View view ) {
// Do stuff
}

However, when I click the "button", I get: could not find a method cancel(View) in the activity class android.view.ContextThemeWrapper for onClick handler...

...what gives?

Was it helpful?

Solution

Apparently this is how it's done:

    FrameLayout cancelButton = ( FrameLayout ) actionBar.getCustomView ().findViewById ( R.id.actionbar_cancel );

    cancelButton.setOnClickListener ( new OnClickListener () {

        @Override
        public void onClick ( View v ) {
            // DO STUFF
        }
    } );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top