1
votes

I'm using ActionBarRTLizer for making the Home Button and the MenuItems to be from right to left instead from left to right, and i got it working in the MainActivity and everything is good except that when i open a Fragment using the Fragment Transaction the ActionBar returns to it's default state (LTR).

So i tried to @Override the onPrepareOptionsMenu() in the fragment but it didn't work. The ActionBar just got messed up.(see Below screenshots

Anyone knows how to deal with that ?

Thanks in advance

EDITED:

This is onCreateOptionsMenu in MainActivity:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.main, menu);

        ActionBarRtlizer rtlizer = new ActionBarRtlizer(this);
        ViewGroup homeView = (ViewGroup) rtlizer.getHomeView();

        RtlizeEverything.rtlize(rtlizer.getActionBarView());

        if (rtlizer.getHomeViewContainer() instanceof ViewGroup) {
            RtlizeEverything.rtlize((ViewGroup) rtlizer.getHomeViewContainer());
        }

        RtlizeEverything.rtlize(homeView);
        rtlizer.flipActionBarUpIconIfAvailable(homeView);

        return true;
    }

And this is the overridden onPrepareOptionsMenu in the fragment:

@Override
    public void onPrepareOptionsMenu(Menu menu) {
        getActivity().getMenuInflater().inflate(R.menu.main, menu);
        ActionBarRtlizer rtlizer = new ActionBarRtlizer(getActivity());
        ViewGroup homeView = (ViewGroup) rtlizer.getHomeView();

        RtlizeEverything.rtlize(rtlizer.getActionBarView());

        if (rtlizer.getHomeViewContainer() instanceof ViewGroup) {
            RtlizeEverything.rtlize((ViewGroup) rtlizer.getHomeViewContainer());
        }

        RtlizeEverything.rtlize(homeView);
        rtlizer.flipActionBarUpIconIfAvailable(homeView);
        if(radioPlayer.isPlaying()){
            menu.findItem(R.id.action_live_stream).setIcon(R.drawable.ic_action_stop);
        }
    }

This is the main action bar

And this is after i open a fragment:

enter image description here

1

1 Answers

1
votes

Please try overriding onPrepareOptionsMenu and place all the lines of code after getMenuInflater().inflate(R.menu.main, menu); in it