call a main activity method from a Fragment button

1

I'm using a standard android activity, the "Navigation Drawer Activity", and there's a button in the navigation bar

public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }

    if (item.getItemId() == R.id.action_example) {
        Toast.makeText(getActivity(), "Example action.", Toast.LENGTH_SHORT)
                .show();
        //getActivity().drawGraph();
        return true;
    }

And I'd like to call the drawGraphic () method of my main activity just by pressing the

Note that this navigation bar is a fragment

    
asked by anonymous 15.08.2014 / 17:01

1 answer

0

Try:

((Nome da Sua Activity)getActivity()).drawGraph();
    
15.08.2014 / 17:41