Actionsheet-android is an Android Library to build Actionsheet like iOS UIActionSheet component, iOS7 style, custom color etc
- 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.khoyron:Actionsheet-android:4'
}
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("Cancel")
.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)
}
})
- Initialize variable:
ActionSheet actionSheet;
actionSheet = new ActionSheet(MainActivityJava.this, data)
.setTitle("What do you want to do with the file")
.setCancelTitle("Cancel")
.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
}
});
Function | description |
---|---|
.hideTitle() | hide title |
.setFontData(R.font.meryana_script) | change font data |
.setFontCancelTitle(R.font.meryana_script) | change font cancel |
.setFontTitle(R.font.meryana_script) | change font title |
.setSizeTextCancel(30) | change size text cancel |
.setSizeTextData(30) | change size text data |
.setSizeTextTitle(30) | change size text title |
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.