1

Is it possible to change extended drawer's style and use it in activity? If yes how? I'm trying to use this drawer making it transparent in StoreActivity

If you are curious here is my code. HomeNavigation.java, Drawer code

public class HomeNavigation extends AppCompatActivity {
    public DrawerLayout mDrawerLayout;
    public ActionBarDrawerToggle mToggle;
    public Toolbar mToolbar;
    public NavigationView mNavigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawer_navigation);

        mToolbar = (Toolbar) findViewById(R.id.navigation_actionbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setTitle("Welcome Back!");

        mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close);

        mDrawerLayout.addDrawerListener(mToggle);
        mToggle.syncState();

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        /**ON NAVIGATION ITEM SELECTED*/
    }



    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // enabling drawer toggle by clicking on the app icon.
        if (mToggle.onOptionsItemSelected(item)) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

Class I'm trying to use it in StoreActivity.java

public class StoreActivity extends HomeNavigation {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LayoutInflater inflater = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View contentView = inflater.inflate(R.layout.activity_drawer_navigation_transparent, null, false);
        mDrawerLayout.addView(contentView, 0);
        getSupportActionBar().setTitle("");
        mNavigationView.getMenu().getItem(1).setChecked(true);


    }
}
4

0 回答 0