android.widget.EditText#setClickable ( )源码实例Demo

下面列出了android.widget.EditText#setClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mongol-library   文件: MongolInputMethodManager.java
private void setAllowSystemKeyboardOnEditText(EditText editText, boolean allowSystemKeyboard) {
    // TODO this needs to be tested on lower versions!
    // https://stackoverflow.com/a/45229457

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // api 21+
        editText.setShowSoftInputOnFocus(allowSystemKeyboard);
    } else { // api 11+
        if (allowSystemKeyboard) {
            // re-enable keyboard (see https://stackoverflow.com/a/45228867)
            // FIXME this does not necessarily always work
            editText.setTextIsSelectable(false);
            editText.setFocusable(true);
            editText.setFocusableInTouchMode(true);
            editText.setClickable(true);
            editText.setLongClickable(true);
            editText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
            editText.setText(editText.getText(), TextView.BufferType.SPANNABLE);
        } else {
            // disable keyboard
            editText.setTextIsSelectable(true);
        }
    }
}
 
源代码2 项目: biermacht   文件: AlertBuilder.java
public AlertDialog.Builder editTextDisabled(final TextView text, final TextView title, String message) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_edit_text_float_2_4, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final TextView messageView = new TextView(this.context);
  messageView.setText(message);
  messageView.setGravity(Gravity.CENTER);
  alertView.addView(messageView);

  // Set text
  editText.setText(text.getText().toString());

  // Set disabled.
  editText.setEnabled(false);
  editText.setClickable(false);
  editText.setFocusable(false);
  editText.setFocusableInTouchMode(false);

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setPositiveButton(R.string.ok, null);
}
 
源代码3 项目: call_manage   文件: DialpadView.java
/**
 * Whether or not the digits above the dialer can be edited.
 *
 * @param canBeEdited If true, the backspace button will be shown and the digits EditText
 *                    will be configured to allow text manipulation.
 */
public void setDigitsCanBeEdited(boolean canBeEdited) {
    View deleteButton = findViewById(R.id.button_delete);
    deleteButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE);
    View callButton = findViewById(R.id.button_call);
    callButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE);
    EditText digits = (DigitsEditText) findViewById(R.id.digits_edit_text);
    digits.setClickable(canBeEdited);
    digits.setLongClickable(canBeEdited);
    digits.setFocusableInTouchMode(canBeEdited);
    digits.setCursorVisible(canBeEdited);
}
 
源代码4 项目: Pinview   文件: Pinview.java
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
源代码5 项目: AndJie   文件: JieEditTextDel.java
protected void initLayout() {
	context = getContext();
	view = LayoutInflater.from(context).inflate(R.layout.item_editext_del,
			null);
	lefText = (TextView) view.findViewById(R.id.leftText);
	middleText = (EditText) view.findViewById(R.id.middleText);
	rightText = (TextView) view.findViewById(R.id.rightText);
	rightImg = (ImageView) view.findViewById(R.id.right_img);
	middleText.setSingleLine(true);
	middleText.setEllipsize(TruncateAt.END);
	middleText.setClickable(true);
	addListener();
	addView(view);
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    personID = getIntent().getIntExtra(MainActivity.KEY_EXTRA_CONTACT_ID, 0);

    setContentView(R.layout.activity_edit);
    nameEditText = (EditText) findViewById(R.id.editTextName);
    genderEditText = (EditText) findViewById(R.id.editTextGender);
    ageEditText = (EditText) findViewById(R.id.editTextAge);

    saveButton = (Button) findViewById(R.id.saveButton);
    saveButton.setOnClickListener(this);
    buttonLayout = (LinearLayout) findViewById(R.id.buttonLayout);
    editButton = (Button) findViewById(R.id.editButton);
    editButton.setOnClickListener(this);
    deleteButton = (Button) findViewById(R.id.deleteButton);
    deleteButton.setOnClickListener(this);

    dbHelper = new ExampleDBHelper(this);

    if(personID > 0) {
        saveButton.setVisibility(View.GONE);
        buttonLayout.setVisibility(View.VISIBLE);

        Cursor rs = dbHelper.getPerson(personID);
        rs.moveToFirst();
        String personName = rs.getString(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_NAME));
        String personGender = rs.getString(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_GENDER));
        int personAge = rs.getInt(rs.getColumnIndex(ExampleDBHelper.PERSON_COLUMN_AGE));
        if (!rs.isClosed()) {
            rs.close();
        }

        nameEditText.setText(personName);
        nameEditText.setFocusable(false);
        nameEditText.setClickable(false);

        genderEditText.setText((CharSequence) personGender);
        genderEditText.setFocusable(false);
        genderEditText.setClickable(false);

        ageEditText.setText((CharSequence) (personAge + ""));
        ageEditText.setFocusable(false);
        ageEditText.setClickable(false);
    }
}
 
源代码7 项目: biermacht   文件: AlertBuilder.java
public AlertDialog.Builder editTextFloatCheckBoxAlert(final TextView text, final TextView title, boolean checked, final BooleanCallback cb) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_edit_text_float_with_check_box, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final CheckBox checkBox = (CheckBox) alertView.findViewById(R.id.check_box);

  // Set text
  editText.setText(text.getText().toString());

  checkBox.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      cb.call(checkBox.isChecked());
      if (checkBox.isChecked()) {
        editText.setEnabled(false);
        editText.setClickable(false);
        editText.setFocusable(false);
        editText.setFocusableInTouchMode(false);
        editText.setText(text.getText().toString());
      }
      else {
        editText.setEnabled(true);
        editText.setClickable(true);
        editText.setFocusable(true);
        editText.setFocusableInTouchMode(true);
      }
    }
  });

  // Set the box to be checked or not.
  checkBox.setChecked(checked);

  // If checked initially, grey out edit text
  if (checked) {
    editText.setEnabled(false);
    editText.setClickable(false);
    editText.setFocusable(false);
    editText.setFocusableInTouchMode(false);
  }

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
              text.setText(editText.getText().toString());
              callback.call();
              cb.call(checkBox.isChecked());
            }

          })

          .setNegativeButton(R.string.cancel, null);
}
 
源代码8 项目: commcare-android   文件: StringWidget.java
public StringWidget(Context context, FormEntryPrompt prompt, boolean secret, boolean inCompactGroup) {
    super(context, prompt, inCompactGroup);
    mAnswer = (EditText)LayoutInflater.from(getContext()).inflate(getAnswerLayout(), this, false);
    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
    mAnswer.setOnClickListener(this);

    mAnswer.addTextChangedListener(this);

    //Let's see if we can figure out a constraint for this string
    try {
        addAnswerFilter(new InputFilter.LengthFilter(guessMaxStringLength(prompt)));
    } catch (UnpivotableExpressionException e) {
        //expected if there isn't a constraint that does this
    }

    this.secret = secret;

    if (!secret) {
        // capitalize the first letter of the sentence
        mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
    }
    setTextInputType(mAnswer);

    if (!secret) {
        mAnswer.setSingleLine(false);
    }

    if (prompt != null) {
        mReadOnly = prompt.isReadOnly();
        IAnswerData value = prompt.getAnswerValue();
        if (value != null) {
            mAnswer.setText(value.getDisplayText());
        }

        if (mReadOnly) {
            if (value == null) {
                mAnswer.setText("---");
            }
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }
    }

    if (isInCompactMode()) {
        addToCompactLayout(mAnswer);
    } else {
        addView(mAnswer);
    }
}