欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 對(duì)話框sweet-alert-dialog

 更新時(shí)間:2016年09月19日 17:00:33   投稿:lqh  
這篇文章主要介紹了Android 對(duì)話框sweet-alert-dialog的相關(guān)資料,需要的朋友可以參考下

android原生的dialog太生硬了,之前看到了這個(gè)效果非常不錯(cuò)但是沒(méi)有用過(guò),今天給別人推薦使用,他遇到了問(wèn)題,導(dǎo)入后錯(cuò)誤非常多,也沒(méi)有庫(kù)工程。于是自己認(rèn)真看了一下,這是個(gè)AndroidStudio的工程,并且里面還依賴(lài)于materialish-progress工程,也是個(gè)AS的工程。于是打算弄一個(gè)eclipse的版本并且將這兩個(gè)工程融合在一起作為一個(gè)庫(kù)工程XAlertDialogLibrary。使用時(shí)將其作為庫(kù)導(dǎo)入項(xiàng)目中即可。

效果如下

使用起來(lái)非常簡(jiǎn)單,測(cè)試代碼如下:

MainActivity.java

public class MainActivity extends Activity implements View.OnClickListener {
 
  private int i = -1;
 
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.basic_test).setOnClickListener(this);
    findViewById(R.id.under_text_test).setOnClickListener(this);
    findViewById(R.id.error_text_test).setOnClickListener(this);
    findViewById(R.id.success_text_test).setOnClickListener(this);
    findViewById(R.id.warning_confirm_test).setOnClickListener(this);
    findViewById(R.id.warning_cancel_test).setOnClickListener(this);
    findViewById(R.id.custom_img_test).setOnClickListener(this);
    findViewById(R.id.progress_dialog).setOnClickListener(this);
  }
 
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.basic_test:
        // default title "Here's a message!"
        SweetAlertDialog sd = new SweetAlertDialog(this);
        sd.setCancelable(true);
        sd.setCanceledOnTouchOutside(true);
        sd.show();
        break;
      case R.id.under_text_test:
        new SweetAlertDialog(this)
            .setContentText("It's pretty, isn't it?")
            .show();
        break;
      case R.id.error_text_test:
        new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
            .setTitleText("Oops...")
            .setContentText("Something went wrong!")
            .show();
        break;
      case R.id.success_text_test:
        new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
            .setTitleText("Good job!")
            .setContentText("You clicked the button!")
            .show();
        break;
      case R.id.warning_confirm_test:
        new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
            .setTitleText("Are you sure?")
            .setContentText("Won't be able to recover this file!")
            .setConfirmText("Yes,delete it!")
            .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
            @Override
            public void onClick(SweetAlertDialog sDialog) {
              // reuse previous dialog instance
              sDialog.setTitleText("Deleted!")
                  .setContentText("Your imaginary file has been deleted!")
                  .setConfirmText("OK")
                  .setConfirmClickListener(null)
                  .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
            }
            })
            .show();
        break;
      case R.id.warning_cancel_test:
        new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
            .setTitleText("Are you sure?")
            .setContentText("Won't be able to recover this file!")
            .setCancelText("No,cancel plx!")
            .setConfirmText("Yes,delete it!")
            .showCancelButton(true)
            .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
              @Override
              public void onClick(SweetAlertDialog sDialog) {
                // reuse previous dialog instance, keep widget user state, reset them if you need
                sDialog.setTitleText("Cancelled!")
                    .setContentText("Your imaginary file is safe :)")
                    .setConfirmText("OK")
                    .showCancelButton(false)
                    .setCancelClickListener(null)
                    .setConfirmClickListener(null)
                    .changeAlertType(SweetAlertDialog.ERROR_TYPE);
 
                // or you can new a SweetAlertDialog to show
                /* sDialog.dismiss();
                new SweetAlertDialog(SampleActivity.this, SweetAlertDialog.ERROR_TYPE)
                    .setTitleText("Cancelled!")
                    .setContentText("Your imaginary file is safe :)")
                    .setConfirmText("OK")
                    .show();*/
              }
            })
            .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
              @Override
              public void onClick(SweetAlertDialog sDialog) {
                sDialog.setTitleText("Deleted!")
                    .setContentText("Your imaginary file has been deleted!")
                    .setConfirmText("OK")
                    .showCancelButton(false)
                    .setCancelClickListener(null)
                    .setConfirmClickListener(null)
                    .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
              }
            })
            .show();
        break;
      case R.id.custom_img_test:
        new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
            .setTitleText("Sweet!")
            .setContentText("Here's a custom image.")
            .setCustomImage(R.drawable.custom_img)
            .show();
        break;
      case R.id.progress_dialog:
        final SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE)
            .setTitleText("Loading");
        pDialog.show();
        pDialog.setCancelable(false);
        new CountDownTimer(800 * 7, 800) {
          public void onTick(long millisUntilFinished) {
            // you can change the progress bar color by ProgressHelper every 800 millis
            i++;
            switch (i){
              case 0:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.blue_btn_bg_color));
                break;
              case 1:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_50));
                break;
              case 2:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
                break;
              case 3:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_20));
                break;
              case 4:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_blue_grey_80));
                break;
              case 5:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.warning_stroke_color));
                break;
              case 6:
                pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
                break;
            }
          }
 
          public void onFinish() {
            i = -1;
            pDialog.setTitleText("Success!")
                .setConfirmText("OK")
                .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
          }
        }.start();
        break;
    }
  }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="#FFF"
   xmlns:android="http://schemas.android.com/apk/res/android">
 
   <RelativeLayout android:layout_width="match_parent"
      android:paddingBottom="10dp"
      android:layout_height="wrap_content">
 
      <ImageView
         android:id="@+id/logo_img"
         android:layout_width="180dp"
         android:layout_height="wrap_content"
         android:src="@drawable/logo_big"
         android:layout_marginTop="10dp"
         android:layout_marginBottom="15dp"
         android:layout_centerHorizontal="true"
         android:contentDescription="@string/app_name"/>
 
         <TextView
            android:id="@+id/txt_0"
            android:layout_alignLeft="@id/logo_img"
            android:layout_below="@id/logo_img"
            android:layout_marginLeft="15dp"
            android:text="show material progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:textColor="#797979"/>
 
         <Button
            android:layout_centerHorizontal="true"
            android:layout_below="@id/txt_0"
            android:id="@+id/progress_dialog"
            style="@style/dialog_blue_button"
            android:layout_margin="10dp"
            android:text="Try me!"/>
 
        <TextView
            android:id="@+id/txt_1"
            android:layout_alignLeft="@id/logo_img"
            android:layout_below="@id/progress_dialog"
            android:layout_marginLeft="15dp"
            android:text="A basic message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:textColor="#797979"/>
 
        <Button
            android:layout_centerHorizontal="true"
            android:layout_below="@id/txt_1"
            android:id="@+id/basic_test"
            style="@style/dialog_blue_button"
            android:layout_margin="10dp"
            android:text="Try me!"/>
 
       <TextView
           android:id="@+id/txt_2"
           android:layout_alignLeft="@id/logo_img"
           android:layout_below="@id/basic_test"
           android:layout_marginLeft="15dp"
           android:text="A title with a text under"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:textSize="14sp"
           android:layout_marginTop="15dp"
           android:textColor="#797979"/>
 
       <Button
           android:layout_centerHorizontal="true"
           android:layout_below="@id/txt_2"
           android:id="@+id/under_text_test"
           style="@style/dialog_blue_button"
           android:layout_margin="10dp"
           android:text="Try me!"/>
 
       <TextView
           android:id="@+id/txt_3"
           android:layout_alignLeft="@id/logo_img"
           android:layout_below="@id/under_text_test"
           android:layout_marginLeft="15dp"
           android:text="show error message"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:textSize="14sp"
           android:layout_marginTop="15dp"
           android:textColor="#797979"/>
 
       <Button
          android:layout_centerHorizontal="true"
          android:layout_below="@id/txt_3"
          android:id="@+id/error_text_test"
          style="@style/dialog_blue_button"
          android:layout_margin="10dp"
          android:text="Try me!"/>
 
       <TextView
          android:id="@+id/txt_4"
          android:layout_alignLeft="@id/logo_img"
          android:layout_below="@id/error_text_test"
          android:layout_marginLeft="15dp"
          android:text="A success message"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="14sp"
          android:layout_marginTop="15dp"
          android:textColor="#797979"/>
 
       <Button
          android:layout_centerHorizontal="true"
          android:layout_below="@id/txt_4"
          android:id="@+id/success_text_test"
          style="@style/dialog_blue_button"
          android:layout_margin="10dp"
          android:text="Try me!"/>
 
       <TextView
          android:id="@+id/txt_5"
          android:layout_alignLeft="@id/logo_img"
          android:layout_below="@id/success_text_test"
          android:layout_marginLeft="15dp"
          android:text="A warning message, with a listener bind to the Confirm-button..."
          android:layout_width="200dp"
          android:layout_height="wrap_content"
          android:textSize="14sp"
          android:layout_marginTop="15dp"
          android:textColor="#797979"/>
 
      <Button
          android:layout_centerHorizontal="true"
          android:layout_below="@id/txt_5"
          android:id="@+id/warning_confirm_test"
          style="@style/dialog_blue_button"
          android:layout_margin="10dp"
          android:text="Try me!"/>
 
      <TextView
          android:id="@+id/txt_6"
          android:layout_alignLeft="@id/logo_img"
          android:layout_below="@id/warning_confirm_test"
          android:layout_marginLeft="15dp"
          android:text="A warning message, with listeners bind to Cancel and Confirm button..."
          android:layout_width="200dp"
          android:layout_height="wrap_content"
          android:textSize="14sp"
          android:layout_marginTop="15dp"
          android:textColor="#797979"/>
 
      <Button
         android:layout_centerHorizontal="true"
         android:layout_below="@id/txt_6"
         android:id="@+id/warning_cancel_test"
         style="@style/dialog_blue_button"
         android:layout_margin="10dp"
         android:text="Try me!"/>
 
      <TextView
         android:id="@+id/txt_7"
         android:layout_alignLeft="@id/logo_img"
         android:layout_below="@id/warning_cancel_test"
         android:layout_marginLeft="15dp"
         android:text="A message with a custom icon"
         android:layout_width="200dp"
         android:layout_height="wrap_content"
         android:textSize="14sp"
         android:layout_marginTop="15dp"
         android:textColor="#797979"/>
 
     <Button
         android:layout_centerHorizontal="true"
         android:layout_below="@id/txt_7"
         android:id="@+id/custom_img_test"
         style="@style/dialog_blue_button"
         android:layout_margin="10dp"
         android:text="Try me!"/>
 
   </RelativeLayout>
</ScrollView>

XAlertDialogLibrary(eclipse):點(diǎn)此下載

以上就是Android 對(duì)話框sweet-alert-dialog 的資料整理,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • 保持Android Service在手機(jī)休眠后繼續(xù)運(yùn)行的方法

    保持Android Service在手機(jī)休眠后繼續(xù)運(yùn)行的方法

    下面小編就為大家分享一篇保持Android Service在手機(jī)休眠后繼續(xù)運(yùn)行的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • Android提高之多級(jí)樹(shù)形菜單的實(shí)現(xiàn)方法

    Android提高之多級(jí)樹(shù)形菜單的實(shí)現(xiàn)方法

    這篇文章主要介紹了Android多級(jí)樹(shù)形菜單的實(shí)現(xiàn)方法,很實(shí)用的功能,需要的朋友可以參考下
    2014-08-08
  • Android選中突出背景效果的底部導(dǎo)航欄功能

    Android選中突出背景效果的底部導(dǎo)航欄功能

    這篇文章主要介紹了Android選中突出背景效果的底部導(dǎo)航欄功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10
  • Android實(shí)戰(zhàn)之Cocos游戲容器搭建

    Android實(shí)戰(zhàn)之Cocos游戲容器搭建

    這篇文章主要介紹了Android實(shí)戰(zhàn)之Cocos游戲容器搭建,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-06-06
  • Android用文件存儲(chǔ)數(shù)據(jù)的方法

    Android用文件存儲(chǔ)數(shù)據(jù)的方法

    這篇文章主要為大家詳細(xì)介紹了Android用文件存儲(chǔ)數(shù)據(jù)的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • Jetpack Compose修飾符專(zhuān)項(xiàng)精講

    Jetpack Compose修飾符專(zhuān)項(xiàng)精講

    在今年的Google/IO大會(huì)上,亮相了一個(gè)全新的 Android 原生 UI 開(kāi)發(fā)框架-Jetpack Compose, 與蘋(píng)果的SwiftIUI一樣,Jetpack Compose是一個(gè)聲明式的UI框架,它可簡(jiǎn)化并加快Android上的界面開(kāi)發(fā),使用更少的代碼、強(qiáng)大的工具和直觀的 Kotlin API,快速讓?xiě)?yīng)用生動(dòng)而精彩
    2022-10-10
  • Android 自定義Button控件實(shí)現(xiàn)按鈕點(diǎn)擊變色

    Android 自定義Button控件實(shí)現(xiàn)按鈕點(diǎn)擊變色

    這篇文章給大家介紹了android 自定義Button控件實(shí)現(xiàn)按鈕點(diǎn)擊變色的代碼,本文給大家附有注釋?zhuān)浅2诲e(cuò),代碼簡(jiǎn)單易懂,對(duì)android按鈕點(diǎn)擊變色的實(shí)現(xiàn)感興趣的朋友參考下吧
    2016-11-11
  • Android編程實(shí)現(xiàn)攝像頭臨摹效果的方法

    Android編程實(shí)現(xiàn)攝像頭臨摹效果的方法

    這篇文章主要介紹了Android編程實(shí)現(xiàn)攝像頭臨摹效果的方法,涉及Android權(quán)限控制、布局及攝像頭功能調(diào)用等相關(guān)操作技巧,需要的朋友可以參考下
    2017-09-09
  • 解決 INSTALL FAILED CONFLICTING PROVIDER的問(wèn)題方法

    解決 INSTALL FAILED CONFLICTING PROVIDER的問(wèn)題方法

    這篇文章主要介紹了解決 INSTALL FAILED CONFLICTING PROVIDER的問(wèn)題方法的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • Kotlin關(guān)于協(xié)程是什么的探究

    Kotlin關(guān)于協(xié)程是什么的探究

    Android官方對(duì)協(xié)程的定義-協(xié)程是一種并發(fā)設(shè)計(jì)模式,您可以在Android平臺(tái)上使用它來(lái)簡(jiǎn)化異步執(zhí)行的代碼。協(xié)程是在版本1.3中添加到Kotlin的,它基于來(lái)自其他語(yǔ)言的既定概念
    2023-01-01

最新評(píng)論