Android电话号码格式
在x-xxx-xxx-xxxx中使用此格式。请确保我不想附加- 在数字之间。它应该看起来像四个不同的编辑文本和 在每个块上输入后,焦点自动更改为下一个,例如 信用卡支付**Android电话号码格式,android,Android,在x-xxx-xxx-xxxx中使用此格式。请确保我不想附加- 在数字之间。它应该看起来像四个不同的编辑文本和 在每个块上输入后,焦点自动更改为下一个,例如 信用卡支付** **`I want to develop an edit text which saprates the phone number 尝试实现TextWatcher 你可以在这里得到更多的细节。 已编辑 由于您已经实现了TextWatcher(我在发布我的答案后看到了它),第二个链接肯定会对您有所帮助。使用项目中的代码示例
**`I want to develop an edit text which saprates the phone number
尝试实现TextWatcher 你可以在这里得到更多的细节。 已编辑
由于您已经实现了TextWatcher(我在发布我的答案后看到了它),第二个链接肯定会对您有所帮助。使用项目中的代码示例更新您的答案。尽量包含演示特定问题所需的最少代码。此外,您的问题非常广泛。您应该关注将问题进一步细分为更小的功能,例如:“如何在键入不同的textview后聚焦textview”
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<EditText
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:inputType="number"
android:maxLength="15"
android:layout_marginBottom="5dp"/>
</RelativeLayout>
test.addTextChangedListener(new TextWatcher() {
private boolean mFormatting;
private int mAfter;
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if (!mFormatting) {
mFormatting = true;
}
if(mAfter!=0)
PhoneNumberUtils.formatNumber(s,PhoneNumberUtils.getFormatTypeForLocale(Locale.US));
mFormatting = false;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
mAfter = after;
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
}
});