GithubHelp home page GithubHelp logo

dialogplus's Introduction

Android Arsenal API Join the chat at https://gitter.im/orhanobut/dialogplus

DialogPlus

Simple, easy dialog solution for android.


DialogPlus provides 3 types:
  • Top : Dialog will appear at top with animation
  • Center : Dialog will appear in the center with animation
  • Bottom : Dialog will appear at the bottom of the screen with animation
DialogPlus provides 3 content types:
  • ListHolder : Items will be shown in a listview
  • GridHolder : Items will be shown in a gridview
  • ViewHolder : Your customized view will be shown in the content

Gradle

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
    compile 'com.orhanobut:dialogplus:1.2-SNAPSHOT@aar'
}

Usage

Use the builder to create the dialog.

Basic usage

DialogPlus dialog = new DialogPlus.Builder(this)
        .setAdapter(adapter)
        .setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
            }
        })
        .create();
dialog.show();

More options

You can also select different holder for the dialog.

  • Use ListView as content holder, note that this is default content type.
setContentHolder(new ListHolder())
  • Use ViewHolder as content holder if you want to use a custom view for your dialog. Pass resource id
.setContentHolder(new ViewHolder(R.layout.content))

or pass view itself

.setContentHolder(new ViewHolder(view))
  • Use GridHolder if you want to use GridView for the dialog. You must set column number.
.setContentHolder(new GridHolder(COLUMN_NUMBER))
  • Set dialog position. BOTTOM (default), TOP or CENTER
.setGravity(DialogPlus.Gravity.CENTER)
  • Define if the dialog is cancelable and should be closed when back pressed or click outside is pressed
.setCancelable(true)
  • Set Adapter, this adapter will be used to fill the content for ListHolder and GridHolder. This is required if the content holder is ListHolder or GridHolder. It is not required if the content holder is ViewHolder.
.setAdapter(adapter);
  • Set an item click listener when list or grid holder is chosen. In that way you can have callbacks when one of your items is clicked
.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(DialogPlus dialog, Object item, View view, int position) {

    }
})
  • Set a global click listener to you dialog in order to handle all the possible click events. You can then identify the view by using its id and handle the correct behaviour Only views which has id will trigger this event.
.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(DialogPlus dialog, View view) {

    }
})
  • Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins are applied
.setMargins(left, top, right, bottom)
  • Set the footer view using the id of the layout resource
.setFooter(R.layout.footer)

or use view

.setFooter(view)
  • Set the header view using the id of the layout resource
.setHeader(R.layout.header)

or use view

.setHeader(view)
  • Set animation resources
.setInAnimation(R.anim.abc_fade_in)
.setOutAnimation(R.anim.abc_fade_out)
  • Set screen type to either fill the screen or only half
.setScreenType(DialogPlus.ScreenType.FULL)

You might also like

  • Hawk Secure simple key-value storage
  • Wasp All-in-one network solution
  • Bee QA/Debug tool
  • SimpleListView Simple basic listview implementation with linearlayout

License

Copyright 2014 Orhan Obut

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.

dialogplus's People

Contributors

alexbalo avatar gitter-badger avatar orhanobut avatar

Watchers

 avatar  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.