All Projects → Arjun-sna → android-contextual-action-bar

Arjun-sna / android-contextual-action-bar

Licence: other
Customizable action bar for android with context menus

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to android-contextual-action-bar

react-native-floating-action-bar
A React Native floating action bar.
Stars: ✭ 39 (-2.5%)
Mutual labels:  actionbar
React-Native-top-navbar
This reactnative package provides custom header component for mobile apps. also providing utility method to change statusbar color.
Stars: ✭ 27 (-32.5%)
Mutual labels:  actionbar
mcMMOAction
Prints some mcMMO message into the action bar
Stars: ✭ 17 (-57.5%)
Mutual labels:  actionbar
TitleBar
🔥空祖家的标题栏组件
Stars: ✭ 36 (-10%)
Mutual labels:  actionbar
NavigationHeader
Navigation Header library based on MotionLayout inspired by dribble menu design built with MotionLayout and ObjectAnimator.
Stars: ✭ 39 (-2.5%)
Mutual labels:  actionbar

Contextual ActionBar Android Arsenal

A contextual actionbar library with many customisation option.

Demo

Installation

Add dependency in build.gradle

repositories {
        jcenter()
}

dependencies {
    compile 'in.arjsna:cablib:0.0.1'
}

Usage

Include a ViewStub in the layout file where the Contextual Actionbar need to be shown

<ViewStub
    android:id="@+id/cab_stub"
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize" />

Then customise the Contextual Actionbar and show it whenever needed

ContextualActionBar customCab = new ContextualActionBar(MainActivity.this, R.id.cab_stub)
            .setMenu(R.menu.sample_menu) //The menu to inflated
            .setCloseDrawableRes(R.drawable.up_button_white) //Home button drawable
            .setTitle(getResources().getString(R.string.cab_text)) //Title string
            .setLayoutAnim(R.anim.layout_anim) //Enter Animation
            .setTitleTypeFace(Typeface.createFromAsset(MainActivity.this.getAssets(), "fonts/Avenir-Medium.ttf"))
            .start(cabCallback);

private CabCallback cabCallback = new CabCallback() {
        @Override
        public boolean onCreateCab(ContextualActionBar cab, Menu menu) {
            return true;
        }

        @Override
        public boolean onCabItemClicked(MenuItem item) {
            switch (item.getItemId()){
                case R.id.delete_chat_heads:
                    Toast.makeText(MainActivity.this, "Deleted", Toast.LENGTH_SHORT).show();
                    customCab.finish();
                    return true;
                case R.id.select_all:
                    Toast.makeText(MainActivity.this, "Selected all", Toast.LENGTH_SHORT).show();
                    return true;
                case R.id.select_none:
                    Toast.makeText(MainActivity.this, "Deselected all", Toast.LENGTH_SHORT).show();
                    return true;
                default:
                    return false;
            }
        }

        @Override
        public boolean onDestroyCab(ContextualActionBar cab) {
            return true;
        }
    };

The above initialisation needs to be done only once for a view. You can hide and restore later the same by

customCab.restore();
Note

Forked and enhanced the code from this project https://github.com/afollestad/material-cab

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].