xml:

alter_dialog_two

<?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="wrap_content"
android:orientation="vertical" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:background="@drawable/line_gray_cancel"
android:orientation="vertical" > <TextView
android:id="@+id/tv_alter_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text=""
android:textColor="@android:color/black"
android:textSize="@dimen/dialog_font" /> <View
style="@style/LineHorizontal.Gray_d8"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:orientation="horizontal" > <Button
android:id="@+id/btn_two_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=""
android:background="@drawable/sel_alter_yes_bg"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/blue_03"
android:textSize="@dimen/dialog_font" /> <View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:background="@color/gray_d8" /> <Button
android:id="@+id/btn_two_ok"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=""
android:background="@drawable/sel_alter_no_bg"
android:gravity="center"
android:text="@string/ok"
android:textColor="@color/blue_03"
android:textSize="@dimen/dialog_font" />
</LinearLayout>
</LinearLayout> </LinearLayout>
TwoBtnAlterDialog
package com.android.hcframe.view;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView; import com.android.hcframe.R; public class TwoBtnAlterDialog extends Dialog { private static TwoBtnAlterDialog twoBtnDialog = null;
public static TextView tvAlterContent;
public static Button btn_ok, btn_cancel; public TwoBtnAlterDialog(Context context) {
super(context);
} public TwoBtnAlterDialog(Context context, int theme) {
super(context, theme);
} public static TwoBtnAlterDialog createDialog(Context context,String msg) {
twoBtnDialog = new TwoBtnAlterDialog(context, R.style.CustomAlterDialog);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.alter_dialog_two, null);
twoBtnDialog.setContentView(view);
Window win = twoBtnDialog.getWindow();
win.getAttributes().gravity = Gravity.CENTER;
// win.setWindowAnimations(R.style.dialogWindowAnimTop); tvAlterContent = (TextView) twoBtnDialog.findViewById(R.id.tv_alter_content);
tvAlterContent.setText(msg);
btn_ok = (Button) twoBtnDialog.findViewById(R.id.btn_two_ok);
btn_cancel = (Button) twoBtnDialog.findViewById(R.id.btn_two_cancel);
return twoBtnDialog;
} }

java调用:

 private static TwoBtnAlterDialog alterDialog;

    public static void twoBtnAlterDialog(final Context context, String msg) {
if (alterDialog == null) {
alterDialog = TwoBtnAlterDialog.createDialog(context, msg);
TwoBtnAlterDialog.btn_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, "ok", Toast.LENGTH_SHORT).show();
}
});
TwoBtnAlterDialog.btn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, "cancel", Toast.LENGTH_SHORT).show();
}
});
alterDialog.show();
} else {
alterDialog.dismiss();
alterDialog = null;
} }

最新文章

  1. android 闪屏还是会出现黑屏问题
  2. Edit Distance
  3. 描述性统计分析-用脚本将统计量函数批量化&amp;分步骤逐一写出
  4. gcc编译的四个阶段:预处理,编译,汇编,链接
  5. IOS整体项目层级构建
  6. WebBrowser与IE的关系,如何设置WebBrowser工作在IE9、10、11模式下?
  7. python实现动态更新远程机器列表的SSH登录脚本
  8. XE3随笔8:关于乱码
  9. 【转载】关于Linux Shell 特殊字符
  10. 伪分布式下的hadoop简单配置
  11. *windows文件显示后缀名
  12. javascript检测是否安装了flash
  13. 使用shell+awk完成Hive查询结果格式化输出
  14. 设计模式 -- 解释器模式(Interpreter Pattern)
  15. Centos 在 Xshell里 vim的配置
  16. 从给数组中的对象去重看Javascript中的reduce()
  17. gulp 小坑一个
  18. Web安全测试工具 Burp Suit 使用简介
  19. vue eventBus使用
  20. 日积月累---JVM01

热门文章

  1. 碰到这个SB错误,&#39;Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.点办
  2. hdu 2966 In case of failure k-d树
  3. PHP简单socket编程
  4. centos vim的安装目录在哪里
  5. (五)boost库之随机数random
  6. 电子科大POJ &quot;孤单整数&quot;
  7. ExecuteReader(),ExecuteNonQuery(),ExecuteScalar(),ExecuteXmlReader()之间的区别
  8. Object-c 单例模式中的 allocWithZone作用
  9. cocos2d-x 3.0游戏实例学习笔记《卡牌塔防》第七步---英雄要升级&amp;amp;属性--解析csv配置文件
  10. 字符串对比.net String.EndsWith方法 (String)