Android Phone Number Format -


**`i want develop edit text saprates phone number 

in x-xxx-xxx-xxxx format.make sure not want append - in between number. should 4 different edit text , after entering on each block focus automatically changes next such credit card payments`.**

<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> 

here related activity code-

  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                  }              }); 

try implement textwatcher. http://developer.android.com/reference/android/text/textwatcher.html

you can more details here. https://stackoverflow.com/a/19442743/5829624

edited

as have implemented textwatcher (i have seen after posting answer), second link surely going you.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -