Android Open Source - easy-navigation-drawer Main Activity






From Project

Back to project page easy-navigation-drawer.

License

The source code is released under:

Apache License

If you think the Android project easy-navigation-drawer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package name.roupsky.geno.project;
//from w  w  w  . j  av  a 2  s . c o m
import name.roupsky.geno.easynavigationdrawer.EasyNavigationDrawerBuilder;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends ActionBarActivity implements OnClickListener {

    private static final String EXTRA_THEME = "EXTRA_THEME";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(getIntent().getIntExtra(EXTRA_THEME, R.style.Theme_App));

        super.onCreate(savedInstanceState);

        new EasyNavigationDrawerBuilder()
                .setContentView(R.layout.activity_main)
                .setLeftContentView(R.layout.navigation_menu)
                .install(this);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        // after install the menu is accessible by standard findViewById
        findViewById(android.R.id.button1).setOnClickListener(this);
        findViewById(android.R.id.button2).setOnClickListener(this);
        findViewById(android.R.id.button3).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case android.R.id.button1:
                startActivity(new Intent(this, getClass()).putExtra(EXTRA_THEME, R.style.Theme_App_Light));
                break;
            case android.R.id.button2:
                startActivity(new Intent(this, getClass()).putExtra(EXTRA_THEME, R.style.Theme_App));
                break;
            case android.R.id.button3:
                startActivity(new Intent(this, ChildActivity.class));
                break;
        }
    }

}




Java Source Code List

name.roupsky.geno.easynavigationdrawer.EasyNavigationDrawerBuilder.java
name.roupsky.geno.easynavigationdrawer.EasyNavigationDrawerFragment.java
name.roupsky.geno.project.ChildActivity.java
name.roupsky.geno.project.MainActivity.java