亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android編程使用android-support-design實(shí)現(xiàn)MD風(fēng)格對(duì)話框功能示例

 更新時(shí)間:2017年01月20日 11:42:48   作者:books1958  
這篇文章主要介紹了Android編程使用android-support-design實(shí)現(xiàn)MD風(fēng)格對(duì)話框功能,涉及Android對(duì)話框、視圖、布局相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android編程使用android-support-design實(shí)現(xiàn)MD風(fēng)格對(duì)話框功能。分享給大家供大家參考,具體如下:

首先上效果圖:

 

測(cè)試設(shè)備為紅米Note,系統(tǒng)為Android 4.4.4

說(shuō)明:

1.在新版的android.support.v7包中,Google提供了一個(gè)新的AlertDialog類,即android.support.v7.app.AlertDialog。使用該類中的Builder可以直接創(chuàng)建Material Design風(fēng)格的對(duì)話框,而不需要再借助于第三方庫(kù)。(即第一張圖的效果)

2.遺憾的是,上述第二張圖中轉(zhuǎn)圈樣式的ProgressBar暫無(wú)法使用系統(tǒng)組件。本例中使用的第三方庫(kù)來(lái)自:

compile 'com.github.rahatarmanahmed:circularprogressview:2.4.0'

3.代碼不多,并已簡(jiǎn)單封裝為工具類:

package com.sinatj.demo.utils;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.sinatj.demo.R;
/**
 * UiUtil.
 * Created by admin on 15-12-22.
 */
public class UiUtil {
  private static AlertDialog showDialog(Context context, String title, String message, View contentView,
     String positiveBtnText, String negativeBtnText,
     DialogInterface.OnClickListener positiveCallback,
     DialogInterface.OnClickListener negativeCallback,
     boolean cancelable) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AppCompatAlertDialogStyle);
    builder.setTitle(title == null ? "提示" : title);
    if (message != null) {
      builder.setMessage(message);
    }
    if (contentView != null) {
      builder.setView(contentView);
    }
    if (positiveBtnText != null) {
      builder.setPositiveButton(positiveBtnText, positiveCallback);
    }
    if (negativeBtnText != null) {
      builder.setNegativeButton(negativeBtnText, negativeCallback);
    }
    builder.setCancelable(cancelable);
    return builder.show();
  }
  //普通對(duì)話框
  public static AlertDialog showSimpleDialog(Context context, String title, String message,
        String positiveBtnText, String negativeBtnText,
        DialogInterface.OnClickListener positiveCallback,
        DialogInterface.OnClickListener negativeCallback,
        boolean cancelable) {
    return showDialog(context, title, message, null, positiveBtnText, negativeBtnText, positiveCallback, negativeCallback, cancelable);
  }
  //帶ProgressBar的對(duì)話框
  public static AlertDialog showProgressDialog(Context context, String title, String message,
     String positiveBtnText, String negativeBtnText,
     DialogInterface.OnClickListener positiveCallback,
     DialogInterface.OnClickListener negativeCallback,
     boolean cancelable) {
    View view = LayoutInflater.from(context).inflate(R.layout.circular_progressbar, null);
    if (message != null) {
      final TextView messageTv = (TextView) view.findViewById(R.id.progressbar_msg);
      messageTv.setText(message);
    }
    return showDialog(context, title, null, view, positiveBtnText, negativeBtnText, positiveCallback, negativeCallback, cancelable);
  }
}

4.circular_progressbar布局文件,由一個(gè)第三方庫(kù)提供的ProgressBar和一個(gè)TextView組成:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:padding="20dp">
  <com.github.rahatarmanahmed.cpv.CircularProgressView
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:orientation="vertical"
    app:cpv_animAutostart="true"
    app:cpv_indeterminate="true" />
  <TextView
    android:id="@+id/progressbar_msg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_gravity="center_vertical"
    android:textSize="16sp"
    android:textColor="#111111"
    android:text="@string/main_waiting"/>
</LinearLayout>

5.AppCompatAlertDialogStyle為對(duì)話框的樣式,可指定文字顏色、按鈕顏色、背景色等。(本例中使用的時(shí)默認(rèn)值)

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!--對(duì)話框按鈕文字顏色-->
    <item name="colorAccent">#FFCC00</item>
    <!--對(duì)話框內(nèi)容文字顏色-->
    <item name="android:textColorPrimary">#FFFFFF</item>
    <!--對(duì)話框背景色-->
    <item name="android:background">#5fa3d0</item>
</style>

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android資源操作技巧匯總》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》、《Android開(kāi)發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • android使用surfaceview+MediaPlayer播放視頻

    android使用surfaceview+MediaPlayer播放視頻

    這篇文章主要為大家詳細(xì)介紹了android使用surfaceview+MediaPlayer播放視頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android自定義圓形倒計(jì)時(shí)進(jìn)度條

    Android自定義圓形倒計(jì)時(shí)進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了Android自定義圓形倒計(jì)時(shí)進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • android apk反編譯到j(luò)ava源碼的實(shí)現(xiàn)方法

    android apk反編譯到j(luò)ava源碼的實(shí)現(xiàn)方法

    Android由于其代碼是放在dalvik虛擬機(jī)上的托管代碼,所以能夠很容易的將其反編譯為我們可以識(shí)別的代碼,本文將詳細(xì)介紹,需要的朋友可以參考下
    2012-12-12
  • Android Messenger實(shí)現(xiàn)進(jìn)程間通信及其原理

    Android Messenger實(shí)現(xiàn)進(jìn)程間通信及其原理

    這篇文章主要為大家詳細(xì)介紹了Android Messenger實(shí)現(xiàn)進(jìn)程間通信及其原理,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Android實(shí)現(xiàn)拍照添加時(shí)間水印

    Android實(shí)現(xiàn)拍照添加時(shí)間水印

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)拍照添加時(shí)間水印,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Android 基于google Zxing實(shí)現(xiàn)二維碼、條形碼掃描,仿微信二維碼掃描效果(推薦)

    Android 基于google Zxing實(shí)現(xiàn)二維碼、條形碼掃描,仿微信二維碼掃描效果(推薦)

    這篇文章主要介紹了 Android 基于google Zxing實(shí)現(xiàn)二維碼、條形碼掃描,仿微信二維碼掃描效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下
    2017-01-01
  • Android保存聯(lián)系人到通訊錄的方法

    Android保存聯(lián)系人到通訊錄的方法

    怎么保存聯(lián)系人數(shù)據(jù)到本機(jī)通訊錄?這篇文章主要為大家詳細(xì)介紹了Android保存聯(lián)系人到通訊錄的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • Kotlin?RecyclerView滾動(dòng)控件詳解

    Kotlin?RecyclerView滾動(dòng)控件詳解

    RecyclerView是Android一個(gè)更強(qiáng)大的控件,其不僅可以實(shí)現(xiàn)和ListView同樣的效果,還有優(yōu)化了ListView中的各種不足。其可以實(shí)現(xiàn)數(shù)據(jù)縱向滾動(dòng),也可以實(shí)現(xiàn)橫向滾動(dòng)(ListView做不到橫向滾動(dòng))。接下來(lái)講解RecyclerView的用法
    2022-12-12
  • 詳解Android應(yīng)用中DialogFragment的基本用法

    詳解Android應(yīng)用中DialogFragment的基本用法

    Android App中建議使用DialogFragment作為對(duì)話框的容器,DialogFragment類提供了創(chuàng)建對(duì)話框并管理其外觀需要的所有控件,本文主要內(nèi)容便為詳解Android應(yīng)用中DialogFragment的基本用法,而不再需要調(diào)用Dialog的方法需要的朋友可以參考下
    2016-05-05
  • Android LuBan與Compressor圖片壓縮方式

    Android LuBan與Compressor圖片壓縮方式

    本篇文章主要介紹了Android LuBan與Compressor圖片壓縮方式,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-04-04

最新評(píng)論