Android DigitsKeyListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DigitsKeyListener class.

This code example shows how to use the following methods:
        super(context, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, false));
 
        // ints can only hold 2,147,483,648. we allow 999,999,999 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(9);
        mAnswer.setFilters(fa);
 
        Integer i = getIntegerAnswerValue();
 
        if (i != null) {
            mAnswer.setText(i.toString());
        } 
    } 
 
 
5
CodeRank
This code example shows how to use the following methods:
        super(context, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, true));
 
        // only 15 characters allowed 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(15);
        mAnswer.setFilters(fa);
 
        Double d = getDoubleAnswerValue();
 
        // apparently an attempt at rounding to no more than 15 digit precision??? 
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(15);
        nf.setMaximumIntegerDigits(15);
        nf.setGroupingUsed(false);
        if (d != null) {
5
CodeRank
This code example shows how to use the following methods:
        super(context, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, false));
 
        // ints can only hold 2,147,483,648. we allow 999,999,999 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(9);
        mAnswer.setFilters(fa);
 
        Integer i = getIntegerAnswerValue();
 
        if (i != null) {
            mAnswer.setText(i.toString());
        } 
    } 
 
 
4
CodeRank
This code example shows how to use the following methods:
    	super(activity, widgetAnsweredListener, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, true));
 
        // only 15 characters allowed 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(15);
        mAnswer.setFilters(fa);
 
        Double d = getDoubleAnswerValue();
 
        // apparently an attempt at rounding to no more than 15 digit precision??? 
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(15);
        nf.setMaximumIntegerDigits(15);
        nf.setGroupingUsed(false);
        if (d != null) {
4
CodeRank
This code example shows how to use the following methods:
    	super(activity, widgetAnsweredListener, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, false));
 
        // ints can only hold 2,147,483,648. we allow 999,999,999 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(9);
        mAnswer.setFilters(fa);
 
        Integer i = getIntegerAnswerValue();
 
        if (i != null) {
            mAnswer.setText(i.toString());
        } 
    } 
 
 
4
CodeRank
This code example shows how to use the following methods:
        super(context, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, true));
 
        // only 15 characters allowed 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(15);
        mAnswer.setFilters(fa);
 
        Double d = getDoubleAnswerValue();
 
        // apparently an attempt at rounding to no more than 15 digit precision??? 
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(15);
        nf.setMaximumIntegerDigits(15);
        nf.setGroupingUsed(false);
        if (d != null) {
4
CodeRank
This code example shows how to use the following methods:
		this.txtBox.setKeyListener(new DigitsKeyListener(true,true));		
	} 
	 
	public void makeInteger() 
	{ 
		this.txtBox.setKeyListener(new DigitsKeyListener(true,false));
	} 
 
	@Override 
	public void afterTextChanged(Editable s) {
 
	} 
 
	@Override 
	public void beforeTextChanged(CharSequence s, int start, int count,
			int after) {
 
	} 
 
	@Override 
4
CodeRank
This code example shows how to use the following methods:
    	case INTEGER:
    		return new DigitsKeyListener();
    	case SIGNED:
    		return new DigitsKeyListener(true, false);
    	case DECIMAL:
    		return new DigitsKeyListener(true, true);
    	case NONE:
    	default: 
    		return null; 
    	} 
    } 
    
    public static final int TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000;
 
    /** {@inheritDoc} */ 
    @Override 
    protected View createView(Context c) {
        et = new EditText(c);
        et.setText(answer);
        et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
4
CodeRank
This code example shows how to use the following methods:
    	case INTEGER:
    		return new DigitsKeyListener();
    	case SIGNED:
    		return new DigitsKeyListener(true, false);
    	case DECIMAL:
    		return new DigitsKeyListener(true, true);
    	case NONE:
    	default: 
    		return null; 
    	} 
    } 
    
    public static final int TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000;
 
    /** {@inheritDoc} */ 
    @Override 
    protected View createView(Context c) {
        et = new EditText(c);
        et.setText(answer);
        et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
4
CodeRank
This code example shows how to use the following methods:
		// TODO Auto-generated constructor stub 
	} 
	 
	public void makeNumeric() 
	{ 
		DigitsKeyListener dkl = new DigitsKeyListener(true,true);
		txtBox.setKeyListener(dkl);
	} 
	public String getValue()
	{ 
		return txtBox.getText().toString();
	} 
	 
	public void setValue(String v)
	{ 
		txtBox.setText(v);
	} 
 
} 
4
CodeRank

Related Android DigitsKeyListener Questions & Answers:

See Code Examples for Android DigitsKeyListener Methods: