DialogFragment 实现支付弹出功能

Android DialogFragment 全解析:生命周期、状态管理与工程实践 DialogFragment 是 Android 官方提供的模态对话框解决方案,本质是将 Dialog 的 UI 行为封装在 Fragment 生命周期容器中。其核心原理在于利用 FragmentManager 统一调度生命周期、保障事务原子性,并天然支持配置变更恢复与导航栈管理。相比 AlertDialog.Builder 等瞬时弹窗方案,DialogFragment 提供 ViewModel 集成、SavedStateHandle 持久化、Navigation Component 原生兼容等技术价值,显 阅读详情

区别于 fragment的几个方法


public class PayDetailFragment extends DialogFragment {

      private static final String ARG_PARAM1 = "param1";
     private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String oderprice;
    private String mParam2;

    private OnFragmentInteractionListener mListener;

    private TextView needpayprice;
    private TextView payprice;
    private RelativeLayout rePayWay;
    private LinearLayout LinPayWay;
    private RelativeLayout rePayDetail;
    private RelativeLayout reBalance;
    private RelativeLayout reBalance2;
    private TextView payway_tt;
    private TextView tvbalance;
    private TextView tvbalance2;
    private Button btnPay;

    private Boolean payResult=false;

    public PayDetailFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment PayDetailFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static PayDetailFragment newInstance(String param1, String param2) {
        PayDetailFragment fragment = new PayDetailFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            oderprice = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }



    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // 使用不带Theme的构造器, 获得的dialog边框距离屏幕仍有几毫米的缝隙。
        Dialog dialog = new Dialog(getActivity(), R.style.BottomDialog);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置Content前设定
        dialog.setContentView(R.layout.fragment_pay_detail);
        dialog.setCanceledOnTouchOutside(true); // 外部点击取消
        // 设置宽度为屏宽, 靠近屏幕底部。
        final Window window = dialog.getWindow();
        window.setWindowAnimations(R.style.AnimBottom);
        final WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.BOTTOM; // 紧贴底部
        lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 宽度持平
        lp.height = getActivity().getWindowManager().getDefaultDisplay().getHeight() * 3 / 5;
        window.setAttributes(lp);

        initView(dialog );
        initEvent(dialog);
        return dialog;
    }



    private void initView(Dialog dialog ) {
        payprice=  dialog.findViewById(R.id.pay_price);
        payprice.setText(oderprice);
       needpayprice=dialog.findViewById(R.id.needpay_price);
        needpayprice.setText(oderprice);
        rePayWay = dialog.findViewById(R.id.re_pay_way);
        LinPayWay =  dialog.findViewById(R.id.lin_pay_way);//付款方式
        rePayDetail =  dialog.findViewById(R.id.re_pay_detail);//付款详情
        reBalance = (RelativeLayout) dialog.findViewById(R.id.re_balance);//付款方式(余额)
        reBalance2 = (RelativeLayout) dialog.findViewById(R.id.re_balance2);//付款方式(余额)
        payway_tt=dialog.findViewById(R.id.pay_way_tt);
        tvbalance=dialog.findViewById(R.id.tv_balance);
        tvbalance2=dialog.findViewById(R.id.tv_balance2);
        btnPay = (Button) dialog.findViewById(R.id.btn_confirm_pay);



    }
    private void initEvent(final Dialog dialog) {

        final Animation slide_left_to_left = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_left_to_left);
        final Animation slide_right_to_left = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_right_to_left);
        final Animation slide_left_to_right = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_left_to_right);
        final Animation slide_left_to_left_in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_left_to_left_in);


        rePayWay.setOnClickListener(new View.OnClickListener() {

         @Override
        public void onClick(View view) {
            rePayDetail.startAnimation(slide_left_to_left);
            rePayDetail.setVisibility(View.GONE);
            LinPayWay.startAnimation(slide_right_to_left);
            LinPayWay.setVisibility(View.VISIBLE);

        }
    });

       reBalance.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
             //支付方式改变
             payway_tt.setText(tvbalance.getText());
             payResult=true;
             rePayDetail.startAnimation(slide_left_to_left_in);
             rePayDetail.setVisibility(View.VISIBLE);
             LinPayWay.startAnimation(slide_left_to_right);
             LinPayWay.setVisibility(View.GONE);
         }
     });
        reBalance2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //支付方式改变
                payway_tt.setText(tvbalance2.getText());
                rePayDetail.startAnimation(slide_left_to_left_in);
                rePayDetail.setVisibility(View.VISIBLE);
                LinPayWay.startAnimation(slide_left_to_right);
                LinPayWay.setVisibility(View.GONE);
            }
        });
        btnPay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //回传给Activity状态值

                onButtonPressed(payResult.toString());
                dialog.dismiss();
            }
        });
    }





    // TODO: Rename method, update argument and hook method into UI event
    public void onButtonPressed(String uri) {
        if (mListener != null) {
            mListener.onFragmentInteraction(uri);
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        } else {
            throw new RuntimeException(context.toString()
                    + " must implement OnFragmentInteractionListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    /**
     * This interface must be implemented by activities that contain this
     * fragment to allow an interaction in this fragment to be communicated
     * to the activity and potentially other fragments contained in that
     * activity.
     * <p>
     * See the Android Training lesson <a href=
     * "http://developer.android.com/training/basics/fragments/communicating.html"
     * >Communicating with Other Fragments</a> for more information.
     */
    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        void onFragmentInteraction(String uri);
    }





}

dialog的绘制方式

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">
    <!--==================================付款详情================================-->
    <RelativeLayout
        android:id="@+id/re_pay_detail"
        android:layout_width="match_parent"
        android:layout_height="fill_parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="15dp">

                    <ImageView
                        android:layout_width="10dp"
                        android:layout_height="10dp"
                         />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="true"
                        android:text="订单详情"
                        android:textSize="15sp" />

                    <ImageView
                        android:layout_width="10dp"
                        android:layout_height="10dp"
                        android:layout_alignParentRight="true"
                         />
                </RelativeLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/line"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="15dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="信用卡还款"
                        android:textColor="@color/text_color_grey" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:text="农业银行"
                        android:textColor="@color/text_color_grey" />

                </RelativeLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/line"/>

                <RelativeLayout
                    android:id="@+id/re_pay_way"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="15dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="支付方式"
                        android:textColor="@color/text_color_grey" />

                    <TextView
                        android:id="@+id/pay_way_tt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:drawablePadding="10dp"
                        android:text="招商银行(尾号2345)"
                        android:textColor="@color/text_color_grey" />

                </RelativeLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/line"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="15dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="订单金额"
                        android:textColor="@color/text_color_grey" />

                    <TextView
                        android:id="@+id/pay_price"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:text="10.00"
                        android:textColor="@color/text_color_grey" />
                </RelativeLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/line"/>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="15dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="需付款" />

                    <TextView
                        android:id="@+id/needpay_price"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:text="10.00" />
                </RelativeLayout>

            </LinearLayout>
        </ScrollView>

        <Button
            android:id="@+id/btn_confirm_pay"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/btn_click"
            android:padding="10dp"
            android:text="确认付款"
            android:textColor="#ffffff" />

    </RelativeLayout>
    <!--=================================付款方式======================================-->
    <LinearLayout
        android:id="@+id/lin_pay_way"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical"
        android:layout_toRightOf="@+id/re_pay_detail"
        android:visibility="gone">


        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:padding="10dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="选择支付方式" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_margin="10dp"
                />
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/line"/>

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

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

        <!--        <com.example.hfs.alipayuidemo.ScrollviewListView
                    android:id="@+id/lv_bank"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:listSelector="#ffffff"/>-->

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="1dp"
                    android:background="#ffffff"

                    android:gravity="center_vertical"
                    android:paddingBottom="15dp"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:paddingTop="15dp"
                    android:text="添加银行卡" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/line"/>

                <RelativeLayout
                    android:id="@+id/re_balance"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="1dp"
                    android:background="#ffffff"
                    android:paddingBottom="10dp"
                    android:paddingLeft="20dp"
                    android:paddingTop="10dp">

                    <ImageView
                        android:id="@+id/img_balance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:src="@drawable/ic_pay_banlance_able"
                       />

                    <TextView
                        android:id="@+id/tv_balance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@+id/img_balance"
                        android:paddingLeft="10dp"
                        android:text="真支付"
                        android:textSize="13sp" />

                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/re_balance2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="1dp"
                    android:background="#ffffff"
                    android:paddingBottom="10dp"
                    android:paddingLeft="20dp"
                    android:paddingTop="10dp">

                    <ImageView
                        android:id="@+id/img_balance2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:src="@drawable/ic_pay_banlance_able"
                        />

                    <TextView
                        android:id="@+id/tv_balance2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignTop="@+id/img_balance2"
                        android:layout_toRightOf="@+id/img_balance2"
                        android:paddingLeft="10dp"
                        android:text="假支付"
                        android:textSize="13sp" />

                </RelativeLayout>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
    <!--====================================支付密码=========================================-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/re_pay_detail"
        android:visibility="gone"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="15dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:paddingTop="15dp">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
           />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:text="输入密码" />
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/line"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:background="#ffffff"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_marginTop="10dp" />
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/line"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:padding="10dp"
            android:text="忘记密码"
            android:textColor="@color/colorstatus"
            android:textSize="12sp" />
    </LinearLayout>
</RelativeLayout>


布局的绘制细节

Android支付底部弹窗自定义dialog Android支付底部弹窗自定义dialog,包含完整自定义控件,以及相应进入退出动画 立即下载

相关推荐

DialogFagment支付弹出框

dialogfragment圆角弹出框,可改变宽度

android仿支付提现功能,Android应用开发Android 仿微信支付密码界面

本文将带你了解Android应用开发Android 仿微信支付密码界面,希望本文对大家学Android有所帮助。使用Bundle bundle = new Bundle();bundle.putString(PayFragment.EXTRA_CONTENT, 提现:¥ + 100.00);PayFragment fragment = new PayFragment();fragment.set...

weixin_39861054的博客 495

APS生产排程系统——ERP、MES、APS系统的关联和区别

APS生产排程系统——ERP、MES、APS系统的关联和区别

这里有一只小马吖 2万+

android中DialogFragment使用

今天使用了一下DialogFragment,记录一下使用的步骤,方便以后查阅。 通过DialogFragment中的onCreateDialog方法创建Dialog,生命周期和Fragment调用有些差别。 onCreateDialog()->onActivityCreated()->onDestroyView() /** * @author xuyan QQ:1213236113

航行在蓝天的蚂蚱 1561

保姆级教程:用Ubuntu 22.04搭建RustDesk中继服务器(含Cloudflare避坑指南)

本教程详细指导如何在Ubuntu 22.04上搭建RustDesk中继服务器,解决跨国远程协作的延迟问题。涵盖环境配置、Rust编译优化、服务部署及Cloudflare代理设置等关键步骤,帮助用户实现高性能的私有中继服务。

weixin_29002209的博客 527

C/C++关于VScode报错“终端将被任务重用,按任意键关闭”的解决方案

这其实不是一种报错,有这个提示的原因是本地端口是被共享的,所以必须关闭一个进程才能执行另一个,只需要对 tasks.json文件做一些修改即可。 报错时候 此时的tasks.json为: { "version": "2.0.0", "command": "g++", "args": ["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.exe"], // 编译命令参数 "problemMatche

Jerry Man的博客 6424

DialogFragment使用时遇到的一些问题

DialogFragment使用时遇到的一些问题官方文档: https://developer.android.com/reference/android/app/DialogFragment.html传递参数 static MyDialogFragment newInstance(int num) { MyDialogFragment f = new MyDialogFr

Maxwell 1万+

SAP License USMM SLAW2 SAP审计

引言 企业每年都会收到SAP License审计邮件,邮件内容大致就是根据贵公司与SAP签定的合同XXX条款规定,贵公司所安装的SAP系统需要进行测定。 关键字: SAP License、 SAP USMM、 SLAW2、 SAP 账号、SAP 账号审计、 SAP License 审计、 SAP 审计报告、SAP 账号优化 SAP License审计邮件 企业每年都会收到SAP License审计邮件,邮件内容大致就是根据贵公司与SAP签定的合同XXX条款规定,贵公司所安...

感悟人生 2977

微信支付android不弹出支付密码窗口,Android自定义View实现微信支付密码输入框

本文实例为大家分享了Android实现微信支付密码输入框的具体代码,供大家参考,具体内容如下效果图项目中使用到了支付密码功能,其实这类界面是比较常用的,涉及支付密码的输入的一般都会用到对的,所以单独地把这部分抽取出来,有需要的朋友可以拿去用哈!效果就是支付,弹出密码框,输入密码,这个过程密码不可见,并且提供一个输入完毕的监听!这个弹出层呢,其实就是一个DialogFragment,逻辑封装在其内部...

weixin_36047554的博客 1478

【100%通过率】2024华为OD机试真题E卷 C++语言 实现【流浪地球】

流浪地球计划在赤道上均匀部署了N个转向发动机,按位置顺序编号为0~N-1。 1) 初始状态下所有的发动机都是未启动状态; 2) 发动机起动的方式分为“手动启动”和“关联启动”两种方式; 3) 如果在时刻1一个发动机被启动,下一个时刻2与之相邻的两个发动机就会被“关联启动”; 4) 如果准备启动某个发动机时,它已经被启动了,则什么都不用做; 5) 发动机0与发动机N-1是相邻; 地球联合政府准备挑选某些发动机在某些时刻进行“手动启动”,当然最终所有的发动机都会被启动。 哪些发动机最晚被启动呢?

MISAYAONE的博客 4210

时间序列预测 | 决策树时间序列预测建模,单步、多步(Python)

时间序列预测 | 决策树时间序列预测建模,单步、多步(Python)

天天酷科研的博客 744

使用DialogFragment实现支付宝支付从底部弹出效果

使用DialogFragment实现支付宝支付从底部弹出效果

凌风1205 2226

Qt代码-军用仿真系统基础框架

ui->mapClickLabel->setText(QString("地图点击:(%.1f, %.1f)米").arg(worldPos.x()).arg(worldPos.y()));emit simulationEvent(QString("添加实体: %1 (ID: %2)").arg(attr.name).arg(entity.id()));// 像素坐标→世界坐标(米)

寒寒豆豆软件公司的博客 168

android dialogfragment弹出问题跳转微信支付返回时重新执行及闪屏问题

一个activity里面弹出dialogfragment弹窗输入金额跳转微信支付,当返回的时候看到弹出重新弹出,还闪屏了,加上如果有请求dialog圈圈,这尼玛看起来有点头痛,测试的人都说眼睛都闪瞎,哎逼到没法只有去看看怎么解决,我先看了一下小米商城,因为上面支付的方式很多,随便找了一个订单去支付选择微信,小米支付窗口是从底部弹出,然后跳转到微信支付界面,当点击返回按钮或者返回键的时候,就出现以上...

qq_34900897的博客 2791

华为od 面试八股文_C++_02_含答案

华为od 面试八股文_C++_02_含答案

MISAYAONE的博客 3121

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

改变FragmentDialog弹出框大小

改变FragmentDialog弹出框大小

DavidVCode的博客 3847

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

关于DialogFragment的返回键处理

最近项目需要做一个仿支付宝付款底部框的东西,用到了DialogFragment,其中需要自己处理返回键,记录一下: if (dialog != null) { dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override

daoxiaomianzi的博客 7236

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

为什么弹窗要选DialogFragment?NiceDialog与传统AlertDialog全面对比

在Android开发中,弹窗是每个应用都绕不开的交互组件,但很多新手在实现弹窗时,第一反应往往是直接new一个系统自带的传统AlertDialog。其实,基于DialogFragment实现的NiceDialog弹窗库,才是兼顾稳定性、可定制性与代码可维护性的更优选择。本文将从生命周期管理、屏幕旋转数据保存、样式定制等维度,全面对比DialogFragment弹窗与传统AlertDialog的区别

gitblog_02158的博客 450

Android仿微信支付密码弹出层

开始 最近项目中使用到了支付密码功能,感觉这类界面应该是比较常用的,涉及支付密码的输入的一般都会用到吧,所以单独地把这部分抽取出来,有需要的朋友可以拿去用用。 预览 使用 这个弹出层是一个DialogFragment,逻辑都封装在其内部,使用起来很简单: Bundle bundle = new Bundle(); bundle.putString(PayFragment.EXTRA_CONTEN...

weixin_33860147的博客 376

Android使用DialogFragment,自定义对话框

Android使用DialogFragment,自定义对话框: 效果图: 当我点击结算时,弹出对话框: 步骤一:创建:pay_dialog_fragment.xml:布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_widt

一条咸鱼 3762

移动支付那点事儿

前言 移动支付其实是非常简单的,因为只要按照第三方的文档来就行了,所以在本次分享中,其实更像是一次开发的纪要,当然也有一些看点。做过支付的人都知道支付的难点其实是在第三方文档和demo上(集中体现文档陈旧、demo容易误导人、槽点太多),那就不得不先来吐槽下微信的开发文档和示例,我相信大部分人都被坑过,没有对比就没有伤害,相对而言,支付宝的的文档就好很多,下面我先说重点再谈支付流程。 ...

weixin_45365889的博客 203

在相亲源码中实现移动支付,也没有那么难

前言 在相亲源码中实现移动支付其实是非常简单的,因为只要按照第三方的文档来就行了,做过支付的人都知道支付的难点其实是在第三方文档和demo上(集中体现文档陈旧、demo容易误导人、槽点太多),那就不得不先来吐槽下WX的开发文档和示例,我相信大部分人都被坑过,没有对比就没有伤害,相对而言,支付宝好很多,下面我先说重点再谈支付流程。 开发优化要点 微信回调返回相亲源码当前页面部分机型会产生一闪而过的黑屏现象,测试机型三星S8,解决方案为在微信回调页面增加透明主题,如下: <!--解决微信支付回调部分

m0_58374018的博客 546

Android DialogFragment(圆角失效和动画失效)

一、概述 需求的效果如下 二、实现过程: 自定义dialog: public class PayDialogFragment extends DialogFragment implements View.OnClickListener { private NoticeDialogListener listener; public PayDialogFragment...

JUN_LLLL的博客 2706

android 提示框 自定义demo,Android使用DialogFragment,自定义对话框

Android使用DialogFragment,自定义对话框:效果图: 当我点击结算时,弹出对话框:步骤一:创建:pay_dialog_fragment.xml:布局:步骤二:创建Fragment继承自DialogFRagment:package com.hlrj.posclound.fragments;import com.hlrj.posclound.R;import android.anno...

weixin_39573512的博客 353

自定义View实现微信支付密码输入框

效果图 项目中使用到了支付密码功能,其实这类界面是比较常用的,涉及支付密码的输入的一般都会用到对的,所以单独地把这部分抽取出来,有需要的朋友可以拿去用哈! 效果就是支付,弹出密码框,输入密码,这个过程密码不可见,并且提供一个输入完毕的监听! 这个弹出层呢,其实就是一个DialogFragment,逻辑封装在其内部 一.弹出层进出动画 (anim文件) push_bottom_in...

现状很好 1299
上一篇: RecyclerView 实现购物车功能
下一篇: AppWidgetProvider小部件开发(RemoteViews 机制分析)
Nela
博客等级 码龄11年 9粉丝 71原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值