Skip to content

poteto-dev/android-action-sheet

Repository files navigation

Actionsheet-android

API

Actionshet-android is an Android Library to build Actionshet like iOS UIActionSheet component, iOS7 style, custom color etc

alt text alt text

Installation

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}
  • Add this to your app build.gradle:
dependencies {
	implementation 'com.github.mkhoiron:Actionsheet-android:0.1'
}

Using Java

ArrayList<String> data = new ArrayList<>();

data.add("Delete it");
data.add("Copy");
data.add("Move");
data.add("Duplicate");

new ActionSheet(MainActivityJava.this,data)
                        .setTitle("What do you want to do with the file")
                        .setCancelTitle("Cancle")
                        .setColorTitle(getResources().getColor(R.color.title))
                        .setColorTitleCancel(getResources().getColor(R.color.action))
                        .setColorData(getResources().getColor(R.color.action))
                        .create(new ActionSheetCallBack() {
                            @Override
                            public void data(@NotNull String data, int position) {
                                switch (position){
                                    case 0:
                                        // your action
                                    case 1:
                                        // your action
                                    case 2:
                                        // your action
                                    case 3:
                                        // your action
                                }
                            }
                        });
  • In Kotlin
val data by lazy { ArrayList<String>() }

data.add("English")
data.add("Indonesia")

ActionSheet(this,data)
                   .setTitle("Select Country")
                   .setCancelTitle("Cancel")
                   .setColorTitleCancel(Color.parseColor("#FF4081"))
                   .setColorTitle(Color.parseColor("#FF4081"))
                   .setColorData(Color.parseColor("#FF4081"))
                   .create(object :ActionSheetCallBack{
                       override fun data(data: String, position: Int) {
                           if ("English".equals(data)){
                               // your action
                           }else if("Indonesia".equals(data)){
                               // your action
                           }
                           setToast(data)
                       }
                   })

With variable

  • Initialize variable:
ActionSheet actionSheet;

actionSheet = new ActionSheet(MainActivityJava.this,data)
                        .setTitle("What do you want to do with the file")
                        .setCancelTitle("Cancle")
                        .setColorTitle(getResources().getColor(R.color.title))
                        .setColorTitleCancel(getResources().getColor(R.color.action))
                        .setColorData(getResources().getColor(R.color.action));
                        
actionSheet.create(new ActionSheetCallBack() {
                    @Override
                    public void data(@NotNull String data, int position) {
                        // switch or if handle
                    }
                });

License

Copyright 2018 M Khoiron

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License 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.

Al-hamdulillahi Rabbil 'alamin And Special thanks to JetBrains and jitpack.io for their contributions to this project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published