當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyListener類代碼示例

本文整理匯總了Java中android.text.method.KeyListener的典型用法代碼示例。如果您正苦於以下問題:Java KeyListener類的具體用法?Java KeyListener怎麽用?Java KeyListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyListener類屬於android.text.method包,在下文中一共展示了KeyListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: editPhoneNumber

import android.text.method.KeyListener; //導入依賴的package包/類
/**
 * Tapping the edit icon next to the phone number allows the user to edit their phone
 *
 * @param v v is a View, allows usage of on click in xml
 */
public void editPhoneNumber(View v) {
    editingPhone = true;
    ImageButton cancelButton = (ImageButton) findViewById(R.id.Button_cancelPhoneEdit);
    ImageButton saveButton = (ImageButton) findViewById(R.id.EditButton_savePhoneEdit);
    ImageButton editButton = (ImageButton) findViewById(R.id.ImageButton_phoneEditIcon);
    // Set visibility of the buttons.
    editButton.setVisibility(View.INVISIBLE);
    saveButton.setVisibility(View.VISIBLE);
    cancelButton.setVisibility(View.VISIBLE);
    TextView phoneNumber = (TextView) findViewById(R.id.EditText_phone);
    phoneNumber.setClickable(true);
    // Set it so the user can edit the EditText
    phoneNumber.setFocusableInTouchMode(true);
    phoneNumber.setFocusable(true);
    phoneNumber.setKeyListener((KeyListener) phoneNumber.getTag());
    phoneNumber.requestFocus();
    phoneNumber.moveCursorToVisibleOffset();
    phoneNumber.setText("");
    phoneNumber.append(currentUser.getPhone());
}
 
開發者ID:CMPUT301F16T01,項目名稱:Carrier,代碼行數:26,代碼來源:UserProfileActivity.java

示例2: editEmailAddress

import android.text.method.KeyListener; //導入依賴的package包/類
/**
 * Tapping the edit icon next to the email allows the user to edit their email
 *
 * @param v v is a View, allows usage of on click in xml
 */
public void editEmailAddress(View v) {
    editingEmail = true;
    ImageButton cancelButton = (ImageButton) findViewById(R.id.ImageButton_cancelEmailEdit);
    ImageButton saveButton = (ImageButton) findViewById(R.id.EditButton_saveEmail);
    ImageButton editButton = (ImageButton) findViewById(R.id.ImageButton_emailEditIcon);
    // Set visibility of the buttons.
    editButton.setVisibility(View.INVISIBLE);
    saveButton.setVisibility(View.VISIBLE);
    cancelButton.setVisibility(View.VISIBLE);
    EditText emailView = (EditText) findViewById(R.id.EditText_email);
    // Set it so the user can edit the EditText
    emailView.setFocusableInTouchMode(true);
    emailView.setClickable(true);
    emailView.setKeyListener((KeyListener) emailView.getTag());
    emailView.requestFocus();
    emailView.setText("");
    emailView.append(currentUser.getEmail());
}
 
開發者ID:CMPUT301F16T01,項目名稱:Carrier,代碼行數:24,代碼來源:UserProfileActivity.java

示例3: setKeyListener

import android.text.method.KeyListener; //導入依賴的package包/類
/**
 * Sets the key listener to be used with this TextView.  This can be null
 * to disallow user input.  Note that this method has significant and
 * subtle interactions with soft keyboards and other input method:
 * see {@link KeyListener#getInputType() KeyListener.getContentType()}
 * for important details.  Calling this method will replace the current
 * content type of the text view with the content type returned by the
 * key listener.
 * <p>
 * Be warned that if you want a TextView with a key listener or movement
 * method not to be focusable, or if you want a TextView without a
 * key listener or movement method to be focusable, you must call
 * {@link #setFocusable} again after calling this to get the focusability
 * back the way you want it.
 *
 * @attr ref android.R.styleable#TextView_numeric
 * @attr ref android.R.styleable#TextView_digits
 * @attr ref android.R.styleable#TextView_phoneNumber
 * @attr ref android.R.styleable#TextView_inputMethod
 * @attr ref android.R.styleable#TextView_capitalize
 * @attr ref android.R.styleable#TextView_autoText
 */
public void setKeyListener(KeyListener input) {
    setKeyListenerOnly(input);
    fixFocusableAndClickableSettings();

    if (input != null) {
        try {
            mInputType = mInput.getInputType();
        } catch (IncompatibleClassChangeError e) {
            mInputType = EditorInfo.TYPE_CLASS_TEXT;
        }
        if ((mInputType&EditorInfo.TYPE_MASK_CLASS)
                == EditorInfo.TYPE_CLASS_TEXT) {
            if (mSingleLine) {
                mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
            } else {
                mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
            }
        }
    } else {
        mInputType = EditorInfo.TYPE_NULL;
    }

    InputMethodManager imm = InputMethodManager.peekInstance();
    if (imm != null) imm.restartInput(this);
}
 
開發者ID:jiro-aqua,項目名稱:JotaTextEditor,代碼行數:48,代碼來源:TextView.java

示例4: getKeyListenerForType

import android.text.method.KeyListener; //導入依賴的package包/類
/** gets the key listener by type */
private static KeyListener getKeyListenerForType(NumericType type) {
	switch (type) {
	case DIALPAD:
		return new DialerKeyListener();
	case INTEGER:
		return new DigitsKeyListener();
	case SIGNED:
		return new DigitsKeyListener(true, false);
	case DECIMAL:
		return new DigitsKeyListener(true, true);
	case NONE:
	default:
		return null;
	}
}
 
開發者ID:SahilArora92,項目名稱:vit-04,代碼行數:17,代碼來源:TextEntryElement.java

示例5: createView

import android.text.method.KeyListener; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
protected View createView(Context c) {
    et = new EditText(c);
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
    		LayoutParams.WRAP_CONTENT));
    if (!NumericType.NONE.equals(numericType)) {
    	KeyListener listener = getKeyListenerForType(numericType);
    	if (listener != null)
    		et.setKeyListener(listener);
    } else {
    	et.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | 
    			TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    }
    return encapsulateQuestion(c, et);
}
 
開發者ID:SahilArora92,項目名稱:vit-04,代碼行數:18,代碼來源:TextEntryElement.java

示例6: getKeyListenerForType

import android.text.method.KeyListener; //導入依賴的package包/類
/** gets the key listener by type */
protected static KeyListener getKeyListenerForType(NumericType type) {
	switch (type) {
	case DIALPAD:
		return new DialerKeyListener();
	case INTEGER:
		return new DigitsKeyListener();
	case SIGNED:
		return new DigitsKeyListener(true, false);
	case DECIMAL:
		return new DigitsKeyListener(true, true);
	case NONE:
	default:
		return null;
	}
}
 
開發者ID:SanaMobile,項目名稱:sana.mobile,代碼行數:17,代碼來源:TextEntryElement.java

示例7: createView

import android.text.method.KeyListener; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
protected View createView(Context c) {
    et = new EditText(c);
    et.setBackgroundResource(R.drawable.oval);
    et.setTextColor(c.getResources()
            .getColorStateList(R.color.primary_text_holo_light));
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
    		LayoutParams.WRAP_CONTENT));
    if (!NumericType.NONE.equals(numericType)) {
    	KeyListener listener = getKeyListenerForType(numericType);
    	if (listener != null)
    		et.setKeyListener(listener);
    } else {
    	et.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | 
    			TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    }
    return encapsulateQuestion(c, et);
}
 
開發者ID:SanaMobile,項目名稱:sana.mobile,代碼行數:21,代碼來源:TextEntryElement.java

示例8: setReadOnly

import android.text.method.KeyListener; //導入依賴的package包/類
@Override
public void setReadOnly(boolean value) {
    KeyListener keyListener = getKeyListener();
    if (value) {
        setKeyListener(null);
    } else {
        if (keyListener != null)
            setKeyListener(keyListener);
    }
}
 
開發者ID:Light-Team,項目名稱:ModPE-IDE-Source,代碼行數:11,代碼來源:LModEditor.java

示例9: setKeyListenerOnly

import android.text.method.KeyListener; //導入依賴的package包/類
private void setKeyListenerOnly(KeyListener input) {
    if (mEditor == null && input == null) return; // null is the default value

    createEditorIfNeeded();
    if (mEditor.mKeyListener != input) {
        mEditor.mKeyListener = input;
        if (input != null && !(mText instanceof Editable)) {
            setText(mText);
        }

        setFilters((Editable) mText, mFilters);
    }
}
 
開發者ID:AungThiha,項目名稱:Tada,代碼行數:14,代碼來源:TextView.java

示例10: setEditable

import android.text.method.KeyListener; //導入依賴的package包/類
static void setEditable( EditText et, MyKeyboard kbd, KeyListener kl, boolean editable, int flag )
{
  if ( TDSetting.mKeyboard ) {
    et.setKeyListener( null );
    et.setClickable( true );
    et.setFocusable( editable );
    if ( editable ) {
      registerEditText( kbd, et, flag );
      // et.setKeyListener( mKeyboard );
      et.setBackgroundResource( android.R.drawable.edit_text );
    } else {
      registerEditText( kbd, et, flag | FLAG_NOEDIT );
      et.setBackgroundColor( TDColor.MID_GRAY );
    }
  } else {
    if ( editable ) {
      et.setKeyListener( kl );
      et.setBackgroundResource( android.R.drawable.edit_text );
      et.setClickable( true );
      et.setFocusable( true );
    } else {
      // et.setFocusable( false );
      // et.setClickable( false );
      et.setKeyListener( null );
      et.setBackgroundColor( TDColor.MID_GRAY );
    }
  }
}
 
開發者ID:marcocorvi,項目名稱:topodroid,代碼行數:29,代碼來源:MyKeyboard.java

示例11: setEditable

import android.text.method.KeyListener; //導入依賴的package包/類
private void setEditable( EditText et, KeyListener kl, boolean editable, int flag )
{
  if ( TDSetting.mKeyboard ) {
    et.setKeyListener( null );
    et.setClickable( true );
    et.setFocusable( editable );
    if ( editable ) {
      MyKeyboard.registerEditText( mKeyboard, et, flag );
      // et.setKeyListener( mKeyboard );
      et.setBackgroundResource( android.R.drawable.edit_text );
    } else {
      MyKeyboard.registerEditText( mKeyboard, et, flag | MyKeyboard.FLAG_NOEDIT );
      et.setBackgroundColor( TDColor.MID_GRAY );
    }
  } else {
    if ( editable ) {
      et.setKeyListener( kl );
      et.setBackgroundResource( android.R.drawable.edit_text );
      et.setClickable( true );
      et.setFocusable( true );
    } else {
      // et.setFocusable( false );
      // et.setClickable( false );
      et.setKeyListener( null );
      et.setBackgroundColor( TDColor.MID_GRAY );
    }
  }
}
 
開發者ID:marcocorvi,項目名稱:topodroid,代碼行數:29,代碼來源:CalibGMDialog.java

示例12: setKeyListenerOnly

import android.text.method.KeyListener; //導入依賴的package包/類
private void setKeyListenerOnly(KeyListener input) {
    mInput = input;
    if (mInput != null && !(mText instanceof Editable))
        setText(mText);

    setFilters((Editable) mText, mFilters);
}
 
開發者ID:jiro-aqua,項目名稱:JotaTextEditor,代碼行數:8,代碼來源:TextView.java

示例13: clearMetaKeyStates

import android.text.method.KeyListener; //導入依賴的package包/類
public boolean clearMetaKeyStates(int states) {
    final Editable content = getEditable();
    if (content == null) return false;
    KeyListener kl = mTextView.getKeyListener();
    if (kl != null) {
        try {
            kl.clearMetaKeyState(mTextView, content, states);
        } catch (AbstractMethodError e) {
            // This is an old listener that doesn't implement the
            // new method.
        }
    }
    return true;
}
 
開發者ID:jiro-aqua,項目名稱:JotaTextEditor,代碼行數:15,代碼來源:EditableInputConnection.java

示例14: processKeyDown

import android.text.method.KeyListener; //導入依賴的package包/類
/**
 * onKeyDown()
 */
@Override
public boolean processKeyDown(int keyCode, KeyEvent event) {
    
    if (mEchoEditText != null && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        KeyListener keyListener = mEchoEditText.getKeyListener();
        keyListener.onKeyDown(mEchoEditText, mEchoEditText.getEditableText(), keyCode, event);
        return true;
    }
    return false;
}
 
開發者ID:andraus,項目名稱:BluetoothHidEmu,代碼行數:14,代碼來源:GenericUiControls.java

示例15: processKeyUp

import android.text.method.KeyListener; //導入依賴的package包/類
/**
 * onKeyUp()
 */
@Override
public boolean processKeyUp(int keyCode, KeyEvent event) {

    if (mEchoEditText != null && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        KeyListener keyListener = mEchoEditText.getKeyListener();
        keyListener.onKeyUp(mEchoEditText, mEchoEditText.getEditableText(), keyCode, event);
        return true;
    }

    return false;
}
 
開發者ID:andraus,項目名稱:BluetoothHidEmu,代碼行數:15,代碼來源:GenericUiControls.java


注:本文中的android.text.method.KeyListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。