如何格式化用PhoneNumberUtils电话号码?电话号码、PhoneNumberUtils

由网友(Colorful world 花花世界)分享简介:我如何格式化使用一个电话号码PhoneNumberUtils?How can I format a phone number using PhoneNumberUtils?例如: 1234567890 →(123)456-7890 推荐答案在最基本的:String formattedNumber = Pho...

我如何格式化使用一个电话号码PhoneNumberUtils?

How can I format a phone number using PhoneNumberUtils?

例如: 1234567890 (123)456-7890

推荐答案

在最基本的:

String formattedNumber = PhoneNumberUtils.formatNumber(unformattedNumber);

根据该国的数量从规则这将自动格式化数。

This will automatically format the number according to the rules for the country the number is from.

您也可以使用格式化就地编辑的文本:

You can also format Editable text in-place using:

PhoneNumberUtils.formatNumber(Editable text, int defaultFormattingType);

看看PhoneNumberUtils查看更多选项。

Take a look at PhoneNumberUtils for more options.

阅读全文

相关推荐

最新文章