Android Open Source - material-menu Custom View Activity






From Project

Back to project page material-menu.

License

The source code is released under:

Apache License

If you think the Android project material-menu 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 com.balysv.materialmenu.demo.abs;
// ww w.j  av  a  2  s  .com
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.balysv.materialmenu.MaterialMenuView;
import com.balysv.materialmenu.demo.R;

import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;

public class CustomViewActivity extends BaseActivity implements View.OnClickListener {

    private MaterialMenuView materialMenu;
    private int              actionBarMenuState;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initCustomActionBar();
        helper.init(getWindow().getDecorView(), materialMenu);
    }

    private void initCustomActionBar() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setHomeButtonEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(R.layout.action_bar);
        materialMenu = (MaterialMenuView) actionBar.getCustomView().findViewById(R.id.action_bar_menu);
        materialMenu.setOnClickListener(this);
    }

    @Override public void onClick(View v) {
        if (v.getId() == R.id.action_bar_menu) {
            // random state on click
            actionBarMenuState = generateState(actionBarMenuState);
            materialMenu.animatePressedState(intToState(actionBarMenuState));
            return;
        }
        helper.onClick(v);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.custom_view, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            startActivity(new Intent(this, HomeIconActivity.class));
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

com.balysv.materialmenu.MaterialMenuBase.java
com.balysv.materialmenu.MaterialMenuDrawable.java
com.balysv.materialmenu.MaterialMenuIcon.java
com.balysv.materialmenu.MaterialMenuView.java
com.balysv.materialmenu.MaterialMenu.java
com.balysv.materialmenu.demo.BaseActivityHelper.java
com.balysv.materialmenu.demo.abc.BaseActivity.java
com.balysv.materialmenu.demo.abc.CustomViewActivity.java
com.balysv.materialmenu.demo.abc.HomeIconActivity.java
com.balysv.materialmenu.demo.abs.BaseActivity.java
com.balysv.materialmenu.demo.abs.CustomViewActivity.java
com.balysv.materialmenu.demo.abs.HomeIconActivity.java
com.balysv.materialmenu.demo.stock.BaseActivity.java
com.balysv.materialmenu.demo.stock.CustomViewActivity.java
com.balysv.materialmenu.demo.stock.HomeIconActivity.java
com.balysv.materialmenu.demo.toolbar.ToolbarActivity.java
com.balysv.materialmenu.extras.abc.MaterialMenuIconCompat.java
com.balysv.materialmenu.extras.abs.MaterialMenuIconSherlock.java
com.balysv.materialmenu.extras.toolbar.MaterialMenuIconToolbar.java