GithubHelp home page GithubHelp logo

l-dialogs's Introduction

L-Dialogs


A small library replicating the new dialogs in android L.

"Screenshot 1"


Set Up (Android Studio):

Download the aar here: https://www.dropbox.com/s/uqey0k7m3g45ky4/app.aar

You can rename the aar and then place it in the libs directory of your project.

Go into your build.gradle and add the following:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'uk.me.lewisdeane.ldialogs:RENAMED_FILE_NAME_HERE@aar'
}

repositories{
    flatDir{
        dirs 'libs'
    }
}

Usage

##Normal Dialogs

You should now be able to access the class CustomDialog from one of your java files.

To create a new CustomDialog simply call

CustomDialog customDialog = new CustomDialog(Context, Title, Content, PositiveText, NegativeText);
or
CustomDialog customDialog = new CustomDialog(Context);
or
CustomDialog customDialog = new CustomDialog(Context, Title, Content, PositiveText);

and then 

customDialog.show();

Method calls are also available

.setConfirmColour(String hex);
.setTitle(String title);
.setContent(String content);
.setConfirm(String confirm);
.setCancel(String cancel);

In order to set the click listeners for the two buttons either implement CustomDialog.ClickListener in the activity that created the dialog or simply use the method:

.setClickListener(new CustomDialog.ClickListener(){...}

and then use the methods below to control behaviour on each button click.

public void onConfirmClick(){
...
}

public void onCancelClick(){
...
}

##List Dialogs

You can access the class CustomListDialog in a similar fashion to previously.

To create a new list dialog simply call

CustomListDialog customListDialog = new CustomListDialog(Context context);
or
CustomListDialog customListDialog = new CustomListDialog(Context context, String title, ArrayList<String> items);
or
CustomListDialog customListDialog = new CustomListDialog(Context context, String title, String[] items);

and then

customListDialog.show();

Method calls are just as easy:

.setTitle(String title);
.setItems(ArrayList<String> items);
.setItems(String[] items);
.setTitleCenterAligned(boolean isCentered);
.setItemsCenterAligned(boolean isCentered);
.setTitleColour(String hexColour);
.setListItemColour(String hexColour);

In order to recieve the click events from the dialog, either implement CustomListDialog.ListClickListener in the activity that created the dialog or just use the method:

.setListClickListener(new CustomListDialog.ListClickListener(){...})

and then use the method below to control behaviour on item click:

public void onListItemSelected(int position, ArrayList<String> items, String item){
    // position is the position in list of selected item.
    // items is the list that is filling the dialog.
    // item is the selected item therefore item = items.get(position);
    
    // Do stuff here based on item click.
}

This library will be updated often, enjoy!

l-dialogs's People

Contributors

lewisjdeane avatar chrismcmine avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.