All Projects → yanzhenjie → CompatAlertDialog

yanzhenjie / CompatAlertDialog

Licence: Apache-2.0 license
No description or website provided.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to CompatAlertDialog

Android-Dialog
Android Dialog(BaseDialog、AlertDialog、ProgressDialog、SuccessDdialog、ErrorDialog、BottomDialog)
Stars: ✭ 36 (+33.33%)
Mutual labels:  dialog, alertdialog
XStyleDialog
可定制化样式的Android Dialog
Stars: ✭ 37 (+37.04%)
Mutual labels:  dialog, alertdialog
KotlinDialogs
对话框工具,Dialog集合工具,引用了V7包的AlertDialog 使用的 kotlin_version = '1.3.11'写的
Stars: ✭ 16 (-40.74%)
Mutual labels:  dialog, alertdialog
wui
Collection of GUI widgets for the web
Stars: ✭ 44 (+62.96%)
Mutual labels:  dialog
LSDialogViewController
Custom Dialog for iOS written in Swift
Stars: ✭ 74 (+174.07%)
Mutual labels:  dialog
few shot dialogue generation
Dialogue Knowledge Transfer Networks (DiKTNet)
Stars: ✭ 24 (-11.11%)
Mutual labels:  dialog
dynamic-dialogs
Display improved dialogs and dialog fragments on Android.
Stars: ✭ 33 (+22.22%)
Mutual labels:  dialog
MultiDialog
MultiDialog utilizes jQuery UI Dialog Widget for a full featured Modalbox / Lightbox application.
Stars: ✭ 23 (-14.81%)
Mutual labels:  dialog
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (+255.56%)
Mutual labels:  dialog
MaterialSurface
Google's Material Design UI library for Winform C# ./
Stars: ✭ 34 (+25.93%)
Mutual labels:  dialog
DEMOS TO MySelf Android
自己平时的一些积累,相当于自己的一个demo库,比较杂,后续会一个一个整理出来
Stars: ✭ 36 (+33.33%)
Mutual labels:  dialog
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (+7.41%)
Mutual labels:  dialog
FabDialog
🎈 Fab into Dialog Animation on Android
Stars: ✭ 36 (+33.33%)
Mutual labels:  dialog
alert
Cross-platform, isomorphic alert, for Node and browser (previously alert-node)
Stars: ✭ 27 (+0%)
Mutual labels:  dialog
AttributionPresenter
An Android library to easily display attribution information of open source libraries.
Stars: ✭ 47 (+74.07%)
Mutual labels:  dialog
Personal-Emotional-Stylized-Dialog
A Paper List for Personalized, Emotional, and stylized Dialog
Stars: ✭ 112 (+314.81%)
Mutual labels:  dialog
flutter page tracker
flutter埋点、弹窗埋点、页面埋点事件捕获框架,支持普通页面的页面曝光事件(PageView),页面离开事件(PageExit)。支持在TabView和PageView组件中发送页面曝光和页面离开
Stars: ✭ 103 (+281.48%)
Mutual labels:  dialog
sweet-modal-vue
The sweetest library to happen to modals.
Stars: ✭ 762 (+2722.22%)
Mutual labels:  dialog
fusion
An Easy-to-use Kotlin based Customizable Modules Collection with Material Layouts by BlackBeared.
Stars: ✭ 39 (+44.44%)
Mutual labels:  dialog
react-redux-modals
This repo created for Medium.com: React/Redux: Modals and Dialogs
Stars: ✭ 30 (+11.11%)
Mutual labels:  dialog

欢迎加入QQ技术交流群:46523908

Material Design风格的AlertDialog,内部在API Version <= 20时使用Appcomat项目的AlertDialog,API Version > 20时,使用系统原生的Alertdialog。

目前是我个人使用,开源的话意义不是特别大,但是我的几个开源项目demo都都要用到,所以整合出来。

引入项目

Gradle

compile 'com.yanzhenjie.alertdialog:alertdialog:1.0.1'

Or Maven:

<dependency>
  <groupId>com.yanzhenjie.alertdialog</groupId>
  <artifactId>AlertDialog</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

lvy:

<dependency org='com.yanzhenjie.alertdialog' name='AlertDialog' rev='1.0.1'>
  <artifact name='AlertDialog' ext='pom' ></artifact>
</dependency>

用法

和系统原生用法一模一样,特点也一模一样的。但是为了照顾小白同学,我还是来个sample。

// 这里注意包别导错了。
// X 不是:android.support.v7.app.AlertDialog
// X 不是:android.app.AlertDialog
// √ 是:com.yanzhenjie.alertdialog.AlertDialog

/**
 * 显示正常用法的按钮。
 */
private void onCommonClick() {
    AlertDialog.newBuilder(this)
        .setTitle("标题")
        .setMessage("提示信息")
        .setNeutralButton("忽略", (dialog, which) -> {
            Toast.makeText(MainActivity.this, "点击了忽略", Toast.LENGTH_SHORT).show();
        })
        .setNegativeButton("取消", (dialog, which) -> {
            Toast.makeText(MainActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
        })
        .setPositiveButton("好的", (dialog, which) -> {
            Toast.makeText(MainActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
        })
        .show();

    //  Button被点击后,不调用dialog.dismiss(),因为AlertDialog会自动调用。
}

/**
 * 特殊用法被点击。
 */
private void onSpecialClick() {
    AlertDialog alertDialog = AlertDialog.newBuilder(this)
        .setTitle("标题")
        .setMessage("提示信息")
        // Listener 写null,Button被点击时,Alertdialog就不会自动dismiss了。
        .setNeutralButton("忽略", null)
        .setNegativeButton("取消", null)
        .setPositiveButton("好的", null)
        .show(); // 这里是直接show(),不是create(),否则不能getButton()。

    // 获取中性按钮。
    Button btnNeutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    btnNeutral.setOnClickListener(v -> {
        Toast.makeText(MainActivity.this, "我们拦截了忽略点击关闭dialog操作",
                Toast.LENGTH_SHORT).show();
    });
    // 获取取消按钮。
    Button btnNegative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    btnNegative.setOnClickListener(v -> {
        alertDialog.dismiss(); // 拦截了btn的默认操作,需要调用dialog.dismiss()。
        Toast.makeText(MainActivity.this, "点击了取消",
                Toast.LENGTH_SHORT).show();
    });
    // 获取确定按钮。
    Button btnPositive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    btnPositive.setOnClickListener(v -> {
        alertDialog.dismiss(); // 拦截了btn的默认操作,需要调用dialog.dismiss()。
        Toast.makeText(MainActivity.this, "点击了确定",
                Toast.LENGTH_SHORT).show();
    });
}

License

Copyright 2017 Yan Zhenjie

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