下面列出了android.widget.EditText#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
EditText editText = mEditText;
editText.setText(getText());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null) {
((ViewGroup) oldParent).removeView(editText);
}
onAddEditTextToDialogView(view, editText);
}
}
private static TextInputLayout getTextInputLayout(EditText editText) {
ViewParent parent = editText.getParent();
while (parent instanceof View) {
if (parent instanceof TextInputLayout) {
return (TextInputLayout) parent;
}
parent = parent.getParent();
}
return null;
}
@SuppressLint("MissingSuperCall")
@Override
protected void onBindDialogView(View view) {
EditText editText = mTextView;
editText.setText(getText());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null) {
((ViewGroup) oldParent).removeView(editText);
}
onAddEditTextToDialogView(view, editText);
}
}
@Override
protected void onBindDialogView(@NonNull View view) {
EditText editText = mEditText;
editText.setText(getText());
// Initialize cursor to end of text
if (editText.getText().length() > 0)
editText.setSelection(editText.length());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null)
((ViewGroup) oldParent).removeView(editText);
onAddEditTextToDialogView(view, editText);
}
}
@SuppressLint("MissingSuperCall")
@Override
protected void onBindDialogView(@NonNull View view) {
EditText editText = mEditText;
editText.setText(getText());
// Initialize cursor to end of text
if (editText.getText().length() > 0)
editText.setSelection(editText.length());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null)
((ViewGroup) oldParent).removeView(editText);
onAddEditTextToDialogView(view, editText);
}
}
private void findViews() {
mIdEditText = (EditText) findViewById(R.id.editText_id);
mIdTextInputLayout = (TextInputLayout) mIdEditText.getParent();
mPasswordEditText = (EditText) findViewById(R.id.editText_password);
mPasswordTextInputLayout = (TextInputLayout) mPasswordEditText.getParent();
dot_ap = (ImageView) findViewById(R.id.dot_ap);
dot_leave = (ImageView) findViewById(R.id.dot_leave);
dot_bus = (ImageView) findViewById(R.id.dot_bus);
mVersionTextView = (TextView) findViewById(R.id.textView_version);
mRememberCheckBox = (CheckBox) findViewById(R.id.checkbox_remember);
mLoginButton = (Button) findViewById(R.id.button_login);
}
@Override
protected void onAddEditTextToDialogView(@NonNull View view, @NonNull EditText editText) {
if (editText.getParent() != null) {
((ViewGroup) mEditText.getParent()).removeView(editText);
}
((ViewGroup) view).addView(
editText,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
);
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
EditText editText = mEditText;
editText.setText(getText());
ViewParent oldParent = editText.getParent();
if (oldParent != view) {
if (oldParent != null) {
((ViewGroup) oldParent).removeView(editText);
}
onAddEditTextToDialogView(view, editText);
}
}
private void setupColors() {
if( settings.tintActionbar() ) {
// the ActionBar can be tinted. This is really cool.
// Get the ActionBar
ActionBar ab = getSupportActionBar();
// Make its background drawable a ColorDrawable
ab.setBackgroundDrawable(new ColorDrawable(_scheme.getBackground()));
_mainToolbar.setBackgroundColor(_scheme.getBackground());
// Create a SpannableString from the current server.
SpannableString st = new SpannableString(server.getTitle());
// Make its forground color (through a ForgroundColorSpan) to be the
// foreground of the scheme.
// This is because you can't guarantee that the ActionBar text color and
// actionbar color aren't going to be the same.
st.setSpan(new ForegroundColorSpan(_scheme.getForeground()),
0, st.length(), SpannableString.SPAN_INCLUSIVE_INCLUSIVE);
// Now, set our spannable to be the ActionBar title.
_mainToolbar.setTitle(st);
} else {
(getSupportActionBar()).setTitle(server.getTitle());
}
EditText input = (EditText)findViewById(R.id.input);
LinearLayout lll = (LinearLayout)(input.getParent());
lll.setBackgroundColor(_scheme.getBackground());
input.setTextColor(_scheme.getForeground());
}