首页 > 解决方案 > 如何更改 CountryCodePicker (CCP) 的对话框

问题描述

如何将 CountryCodePicker (CCP) 标题的对话框从选择国家更改为选择国家或地区。我正在使用国家选择器的 CCP 库。如您所见,下图对话框的标题是选择一个国家。

中共

标签: javaandroidxml

解决方案


非常简单,您检查对话框何时打开,获取标题 textview 并以编程方式更改其文本,如下所示:

CountryCodePicker cpp;
cpp=(CountryCodePicker) findViewById(R.id.yourid);


cpp.setDialogEventsListener(new CountryCodePicker.DialogEventsListener() {
            @Override
            public void onCcpDialogOpen(Dialog dialog) {
                //your code
              TextView title =(TextView)  dialog.findViewById(R.id.textView_title);
              title.setText("Select Country or Region");
            }

            @Override
            public void onCcpDialogDismiss(DialogInterface dialogInterface) {
                //your code
            }

            @Override
            public void onCcpDialogCancel(DialogInterface dialogInterface) {
                //your code
            }
        });

推荐阅读