• 公用提示对话框


     /**
       * @category 弹出提示框
       * @param c:false不显示取消按钮,true为显示
       * */
      @SuppressWarnings("deprecation")
      public static void showHD(Activity mActivity, String text, boolean c) {
        final Dialog dialog = new Dialog(mActivity, R.style.Dialog);
        View view = LayoutInflater.from(mActivity).inflate(R.layout.dialog_hiti, null);
        Button btn_cancle = (Button) view.findViewById(R.id.btn_cancle);
        Button btn_confrim = (Button) view.findViewById(R.id.btn_confrim);
        TextView tv_hint = (TextView) view.findViewById(R.id.tv_msg);
        tv_hint.setText(text);
    
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setContentView(view);
        dialog.show();
    
        WindowManager windowManager = mActivity.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
        lp.width = (int) (display.getWidth());
        dialog.getWindow().setAttributes(lp);
    
        Window dialogWindow = dialog.getWindow();
        if (c) { 
          btn_cancle.setVisibility(View.GONE);
        } else {
          btn_cancle.setVisibility(View.VISIBLE);
        }
        dialogWindow.setGravity(Gravity.CENTER);
        btn_confrim.requestFocus();
        btn_cancle.setOnClickListener(new OnClickListener() {
    
          @Override
          public void onClick(View arg0) {
            dialog.dismiss();
          }
        });
    
        btn_confrim.setOnClickListener(new OnClickListener() {
    
          @Override
          public void onClick(View arg0) {
            dialog.dismiss();
          }
        });
      }
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/white"
        android:orientation="vertical" >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:text="提示"
            android:textColor="@color/btn_red"
            android:textSize="18sp" />
    
        <View
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="@color/btn_blue" />
    
        <TextView
            android:id="@+id/tv_msg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:textColor="@color/black"
            android:textSize="18sp" />
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:orientation="horizontal" >
    
            <Button
                android:id="@+id/btn_cancle"
                android:layout_width="0dp"
                android:layout_height="40dp"
                android:layout_margin="20dp"
                android:layout_weight="1"
                android:background="@color/btn_yellow"
                android:text="取消"
                android:textColor="@color/white" />
    
            <Button
                android:id="@+id/btn_confrim"
                android:layout_width="0dp"
                android:layout_height="40dp"
                android:layout_margin="20dp"
                android:layout_weight="1"
                android:background="@color/btn_red"
                android:text="确定"
                android:textColor="@color/white" />
        </LinearLayout>
    
    </LinearLayout>
  • 相关阅读:
    网络世界中的图片以及相关的处理
    Ninject 2.x细说1.基本使用
    Orchard1.4新功能自动路由(AutoRouter)并附Orchard最新1.4版汉化包
    json的一点总结
    ASP.NET MVC路由扩展:路由映射
    厚积薄发,丰富的公用类库积累,助你高效进行系统开发(12) 网络相关操作辅助类
    IIS是如何处理ASP.NET请求的
    一周最新示例代码回顾 (3/19–3/25)
    .NET插件系统(三) 插件间通信问题——设计可自组织和注入的组装程序
    缓存总结
  • 原文地址:https://www.cnblogs.com/yico/p/5179112.html
Copyright © 2020-2023  润新知