本文整理汇总了Java中android.widget.EditText.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.getParent方法的具体用法?Java EditText.getParent怎么用?Java EditText.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindDialogView
import android.widget.EditText; //导入方法依赖的package包/类
@SuppressLint("MissingSuperCall")
@Override
protected void onBindDialogView(@NonNull View view) {
EditText editText = this.editText;
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);
}
}
示例2: onAddEditTextToDialogView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onAddEditTextToDialogView(View dialogView, final EditText editText) {
super.onAddEditTextToDialogView(dialogView, editText);
final ViewGroup container = (ViewGroup) editText.getParent();
if (container != null) {
final CheckBox cb = new CheckBox(getContext());
cb.setText(R.string.discoverHttps);
cb.setChecked(true);
final Button b = new Button(getContext());
b.setText(R.string.discoverServer);
container.addView(b, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
container.addView(cb, ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
final ProgressBar p = new ProgressBar(getContext());
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
b.setEnabled(false);
((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);
AsyncTask discoveryTask = new AsyncTask() {
@Override
protected Object doInBackground(Object[] objects) {
ServerDiscovery mDiscovery = new ServerDiscovery((NsdManager) getContext().getSystemService(Context.NSD_SERVICE));
mDiscovery.discover(new ServerDiscovery.DiscoveryListener() {
@Override
public void found(final String serverUrl) {
b.post(new Runnable() {
@Override
public void run() {
editText.setText(serverUrl);
}
});
}
@Override
public void notFound() {
b.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getContext(), getContext().getString(R.string.serverNotFound), Toast.LENGTH_LONG).show();
}
});
}
}, !cb.isChecked(), cb.isChecked());
return null;
}
@Override
protected void onPostExecute(Object o) {
b.setEnabled(true);
((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(true);
}
};
discoveryTask.execute();
}
});
}
}