本文整理匯總了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();
}
});
}
}