欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Android自定義彈出框dialog效果

項目要用到彈出框,還要和蘋果的樣式一樣(Android真是沒地位),所以就自己定義了一個,不是很像(主要是沒圖),但是也還可以。

成都創(chuàng)新互聯(lián)專注于企業(yè)營銷型網(wǎng)站建設(shè)、網(wǎng)站重做改版、剛察網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)、電子商務(wù)商城網(wǎng)站建設(shè)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為剛察等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

廢話不多說了,直接上代碼

1、先看布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:padding="20dp"
 android:orientation="vertical">

 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:gravity="center_horizontal"
  android:background="@drawable/custom_dialog_background"
  android:orientation="vertical">

  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:gravity="center_horizontal"
   android:orientation="vertical">

   <TextView
    android:id="@+id/tv_title_custom_dialog"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:text="提醒"
    android:textColor="#000"
    android:textSize="18dp" />

   <TextView
    android:id="@+id/tv_message_custom_dialog"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:text="您確定要取消訂單嗎" />
  </LinearLayout>

  <View
   android:layout_width="match_parent"
   android:layout_height="0.5dp"
   android:layout_marginTop="20dp"
   android:background="#dfdfdf" />

  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal">

   <Button
    android:id="@+id/btn_negative_custom_dialog"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@android:color/transparent"
    android:text="取消"
    android:textColor="@android:color/holo_blue_dark" />

   <View
    android:layout_width="0.5dp"
    android:layout_height="match_parent"
    android:background="#dfdfdf" />

   <Button
    android:id="@+id/btn_positive_custom_dialog"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@android:color/transparent"
    android:text="確定"
    android:textColor="@android:color/holo_blue_dark" />
  </LinearLayout>
 </LinearLayout>
</LinearLayout>

2、集成dialog重寫了一下

package newair.com.storelibrary.ui.custom.widget;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import newair.com.storelibrary.R;

/**
 * Created by ouhimehime on 16/4/22.
 * ---------自定義提示框-----------
 */
public class CustomDialog extends Dialog {


 public CustomDialog(Context context) {
  super(context);
 }

 public CustomDialog(Context context, int themeResId) {
  super(context, themeResId);
 }

 protected CustomDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
  super(context, cancelable, cancelListener);
 }

 public static class Builder {
  private Context context;
  private String title; //標題
  private String message;//提示消息
  private String negative_text;//消極的
  private String positive_text;//積極的
  private DialogInterface.OnClickListener negativeListener;//消極的監(jiān)聽
  private DialogInterface.OnClickListener positiveListener;//積極的監(jiān)聽

  public Builder(Context context) {
   this.context = context;
  }

  public Builder setTitle(String title) {
   if (title == null) {
    this.title = "提醒";
   }
   this.title = title;
   return this;
  }

  public Builder setMessage(String message) {
   if (message == null) {
    this.message = "您沒有填寫提示信息哦";
   }
   this.message = message;
   return this;
  }

  public Builder setNegativeButton(String negative_text, DialogInterface.OnClickListener negativeListener) {
   if (negative_text == null) {
    this.negative_text = "取消";
   }
   this.negative_text = negative_text;
   this.negativeListener = negativeListener;

   return this;
  }

  public Builder setPositionButton(String positive_text, DialogInterface.OnClickListener positiveListener) {
   if (positive_text == null) {
    this.positive_text = "確定";
   }
   this.positive_text = positive_text;
   this.positiveListener = positiveListener;

   return this;
  }

  private TextView tv_title_custom_dialog; //標題
  private TextView tv_message_custom_dialog;//提示信息
  private Button btn_negative_custom_dialog;//消極
  private Button btn_positive_custom_dialog;//積極


  public CustomDialog create() {
   final CustomDialog dialog = new CustomDialog(context);
   View view = LayoutInflater.from(context).inflate(R.layout.dialog_custom_style_layout, null);
   dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);//加上這一句,取消原來的標題欄,沒加這句之前,發(fā)現(xiàn)在三星的手機上會有一條藍色的線
//   dialog.addContentView(view, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   dialog.setContentView(view, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   tv_title_custom_dialog = (TextView) view.findViewById(R.id.tv_title_custom_dialog);
   tv_message_custom_dialog = (TextView) view.findViewById(R.id.tv_message_custom_dialog);
   btn_negative_custom_dialog = (Button) view.findViewById(R.id.btn_negative_custom_dialog);
   btn_positive_custom_dialog = (Button) view.findViewById(R.id.btn_positive_custom_dialog);
   tv_title_custom_dialog.setText(title);
   tv_message_custom_dialog.setText(message);
   btn_negative_custom_dialog.setText(negative_text);
   btn_positive_custom_dialog.setText(positive_text);
   dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
   btn_negative_custom_dialog.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
     negativeListener.onClick(dialog, Dialog.BUTTON_NEGATIVE);
    }
   });
   btn_positive_custom_dialog.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
     positiveListener.onClick(dialog, Dialog.BUTTON_POSITIVE);
    }
   });
   return dialog;
  }
 }
}

3、使用起來和系統(tǒng)的用法一樣

CustomDialog.Builder builder = new CustomDialog.Builder(this);
    builder.setTitle("購物提醒")
      .setMessage("我是提示信息,大家好好")
      .setNegativeButton("再看看", new DialogInterface.OnClickListener() {
       @Override
       public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        Toast.makeText(GoodsListActivity.this, "點擊了取消按鈕", Toast.LENGTH_SHORT).show();
       }
      })
      .setPositionButton("確定", new DialogInterface.OnClickListener() {
       @Override
       public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        Toast.makeText(GoodsListActivity.this, "點擊了確定按鈕", Toast.LENGTH_SHORT).show();
       }
      })
      .create()
      .show();

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

分享標題:Android自定義彈出框dialog效果
文章地址:http://chinadenli.net/article48/ppcgep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊網(wǎng)站維護、品牌網(wǎng)站制作移動網(wǎng)站建設(shè)、小程序開發(fā)軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
亚洲最新av在线观看| 日韩精品一区二区三区四区| 中文字幕佐山爱一区二区免费| 成人区人妻精品一区二区三区| 五月婷婷综合缴情六月| 欧美日本精品视频在线观看| 亚洲欧美中文字幕精品| 亚洲视频一区二区久久久| 久久午夜福利精品日韩| 在线欧洲免费无线码二区免费| 国产精品蜜桃久久一区二区| 日韩精品中文在线观看| 国产又色又爽又黄又免费| 日本加勒比系列在线播放| 国产老女人性生活视频| 欧美高潮喷吹一区二区| 日韩欧美一区二区不卡视频| 日韩一区二区三区免费av| 欧美一区二区三区十区| 亚洲最新中文字幕在线视频 | 国产午夜精品在线免费看| 香港国产三级久久精品三级| 天海翼精品久久中文字幕| 在线免费国产一区二区| 欧美欧美欧美欧美一区| 草草草草在线观看视频| 日本妇女高清一区二区三区| 国产三级视频不卡在线观看| 人妻内射精品一区二区| 亚洲一区二区三区在线免费| 欧美又大又黄刺激视频| 亚洲欧洲精品一区二区三区| 一区二区福利在线视频| 久久精品国产亚洲熟女| 最新日韩精品一推荐日韩精品| 国产三级黄片在线免费看| 男女午夜福利院在线观看| 东京热男人的天堂一二三区| 国产欧美日韩在线精品一二区 | 欧美一区二区三区五月婷婷| 欧美久久一区二区精品|