Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

DialerFilter

public class DialerFilter
extends RelativeLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.RelativeLayout
         ↳ android.widget.DialerFilter


This class was deprecated in API level 26.
Use a custom view or layout to handle this functionality instead

This widget is a layout that contains several specifically-named child views that handle keyboard entry interpreted as standard phone dialpad digits.

Summary

Inherited XML attributes

Constants

int DIGITS_AND_LETTERS

This mode has both lines

int DIGITS_AND_LETTERS_NO_DIGITS

This mode is when after starting in DIGITS_AND_LETTERS mode the filter has removed all possibility of the digits matching, leaving only the letters line

int DIGITS_AND_LETTERS_NO_LETTERS

This mode is when after starting in DIGITS_AND_LETTERS mode the filter has removed all possibility of the letters matching, leaving only the digits line

int DIGITS_ONLY

This mode has only the digits line

int LETTERS_ONLY

This mode has only the letters line

Inherited constants

Inherited fields

Public constructors

DialerFilter(Context context)
DialerFilter(Context context, AttributeSet attrs)

Public methods

void append(String text)
void clearText()

Clears both the digits and the filter text.

CharSequence getDigits()
CharSequence getFilterText()
CharSequence getLetters()
int getMode()
boolean isQwertyKeyboard()
boolean onKeyDown(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

boolean onKeyUp(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyUp(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER or KeyEvent.KEYCODE_SPACE is released.

void removeFilterWatcher(TextWatcher watcher)
void setDigitsWatcher(TextWatcher watcher)
void setFilterWatcher(TextWatcher watcher)
void setLettersWatcher(TextWatcher watcher)
void setMode(int newMode)

Change the mode of the widget.

Protected methods

void onFinishInflate()

Finalize inflating a view from XML.

void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)

Only show the icon view when focused, if there is one.

void onModeChange(int oldMode, int newMode)

Called right after the mode changes to give subclasses the option to restyle, etc.

Inherited methods

Constants

DIGITS_AND_LETTERS

added in API level 1
public static final int DIGITS_AND_LETTERS

This mode has both lines

Constant Value: 1 (0x00000001)

DIGITS_AND_LETTERS_NO_DIGITS

added in API level 1
public static final int DIGITS_AND_LETTERS_NO_DIGITS

This mode is when after starting in DIGITS_AND_LETTERS mode the filter has removed all possibility of the digits matching, leaving only the letters line

Constant Value: 2 (0x00000002)

DIGITS_AND_LETTERS_NO_LETTERS

added in API level 1
public static final int DIGITS_AND_LETTERS_NO_LETTERS

This mode is when after starting in DIGITS_AND_LETTERS mode the filter has removed all possibility of the letters matching, leaving only the digits line

Constant Value: 3 (0x00000003)

DIGITS_ONLY

added in API level 1
public static final int DIGITS_ONLY

This mode has only the digits line

Constant Value: 4 (0x00000004)

LETTERS_ONLY

added in API level 1
public static final int LETTERS_ONLY

This mode has only the letters line

Constant Value: 5 (0x00000005)

Public constructors

DialerFilter

added in API level 1
public DialerFilter (Context context)

Parameters
context Context

DialerFilter

added in API level 1
public DialerFilter (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Public methods

append

added in API level 1
public void append (String text)

Parameters
text String

clearText

added in API level 1
public void clearText ()

Clears both the digits and the filter text.

getDigits

added in API level 1
public CharSequence getDigits ()

Returns
CharSequence

getFilterText

added in API level 1
public CharSequence getFilterText ()

Returns
CharSequence

getLetters

added in API level 1
public CharSequence getLetters ()

Returns
CharSequence

getMode

added in API level 1
public int getMode ()

Returns
int

isQwertyKeyboard

added in API level 1
public boolean isQwertyKeyboard ()

Returns
boolean

onKeyDown

added in API level 1
public boolean onKeyDown (int keyCode, 
                KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

Parameters
keyCode int: a key code that represents the button pressed, from KeyEvent

event KeyEvent: the KeyEvent object that defines the button action

Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

added in API level 1
public boolean onKeyUp (int keyCode, 
                KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyUp(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER or KeyEvent.KEYCODE_SPACE is released.

Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

Parameters
keyCode int: A key code that represents the button pressed, from KeyEvent.

event KeyEvent: The KeyEvent object that defines the button action.

Returns
boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

removeFilterWatcher

added in API level 1
public void removeFilterWatcher (TextWatcher watcher)

Parameters
watcher TextWatcher

setDigitsWatcher

added in API level 1
public void setDigitsWatcher (TextWatcher watcher)

Parameters
watcher TextWatcher

setFilterWatcher

added in API level 1
public void setFilterWatcher (TextWatcher watcher)

Parameters
watcher TextWatcher

setLettersWatcher

added in API level 1
public void setLettersWatcher (TextWatcher watcher)

Parameters
watcher TextWatcher

setMode

added in API level 1
public void setMode (int newMode)

Change the mode of the widget.

Parameters
newMode int: The mode to switch to.

Protected methods

onFinishInflate

added in API level 1
protected void onFinishInflate ()

Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.

Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.

onFocusChanged

added in API level 1
protected void onFocusChanged (boolean focused, 
                int direction, 
                Rect previouslyFocusedRect)

Only show the icon view when focused, if there is one.

Parameters
focused boolean: True if the View has focus; false otherwise.

direction int: The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT, View.FOCUS_RIGHT, View.FOCUS_FORWARD, or View.FOCUS_BACKWARD. It may not always apply, in which case use the default.

previouslyFocusedRect Rect: The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will be null otherwise.

onModeChange

added in API level 1
protected void onModeChange (int oldMode, 
                int newMode)

Called right after the mode changes to give subclasses the option to restyle, etc.

Parameters
oldMode int

newMode int