Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
phoneedittext default options shall be initialized if developer try t…
Browse files Browse the repository at this point in the history
…o create edittext from code
  • Loading branch information
Leonardo Esparis committed Feb 19, 2017
1 parent a6f8e55 commit 3a00e88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions phoneedittext/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ android {
}
}


dependencies {
compile 'com.android.support:support-annotations:25.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType;
import android.text.Selection;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.widget.EditText;
import android.support.annotation.RequiresApi;


public class PhoneEditText extends EditText {
Expand All @@ -31,6 +33,19 @@ public PhoneEditText(Context context, AttributeSet attrs) {
initialize();
}

public PhoneEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
setCode(p_mDefaultCode);
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public PhoneEditText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initialize();
setCode(p_mDefaultCode);
}

private void initialize() {
// no matter what kind of input type developer will use
// always, phone input type shall be used.
Expand Down

0 comments on commit 3a00e88

Please sign in to comment.