本文整理汇总了Java中com.afollestad.materialdialogs.MaterialDialog.getInputEditText方法的典型用法代码示例。如果您正苦于以下问题:Java MaterialDialog.getInputEditText方法的具体用法?Java MaterialDialog.getInputEditText怎么用?Java MaterialDialog.getInputEditText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.afollestad.materialdialogs.MaterialDialog
的用法示例。
在下文中一共展示了MaterialDialog.getInputEditText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInput
import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
if (mIsFirstTextChanged) {
mIsFirstTextChanged = false;
return;
}
EditText editText = dialog.getInputEditText();
if (editText == null)
return;
int errorResId = 0;
if (input == null || input.length() == 0) {
errorResId = R.string.text_name_should_not_be_empty;
} else if (!input.equals(mExcluded)) {
if (new File(getCurrentDirectory(), mIsDirectory ? input.toString() : input.toString() + ".js").exists()) {
errorResId = R.string.text_file_exists;
}
}
if (errorResId == 0) {
editText.setError(null);
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
} else {
editText.setError(getString(errorResId));
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
}
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:27,代码来源:MyScriptListFragment.java
示例2: onInput
import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
if (mIsFirstTextChanged) {
mIsFirstTextChanged = false;
return;
}
EditText editText = dialog.getInputEditText();
if (editText == null)
return;
int errorResId = 0;
if (input == null || input.length() == 0) {
errorResId = R.string.text_name_should_not_be_empty;
} else if (!input.equals(mExcluded)) {
if (new File(getCurrentDirectory(), mExtension == null ? input.toString() : input.toString() + mExtension).exists()) {
errorResId = R.string.text_file_exists;
}
}
if (errorResId == 0) {
editText.setError(null);
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
} else {
editText.setError(getString(errorResId));
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
}
}
示例3: showKeyboard
import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
public static void showKeyboard(@NonNull final DialogInterface di,
@NonNull final MaterialDialog.Builder builder) {
final MaterialDialog dialog = (MaterialDialog) di;
if (dialog.getInputEditText() == null) return;
dialog.getInputEditText().post(new Runnable() {
@Override
public void run() {
dialog.getInputEditText().requestFocus();
InputMethodManager imm = (InputMethodManager) builder.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(dialog.getInputEditText(), InputMethodManager.SHOW_IMPLICIT);
}
});
}
示例4: hideKeyboard
import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
public static void hideKeyboard(@NonNull final DialogInterface di,
@NonNull final MaterialDialog.Builder builder) {
final MaterialDialog dialog = (MaterialDialog) di;
if (dialog.getInputEditText() == null) return;
InputMethodManager imm = (InputMethodManager) builder.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
final View currentFocus = dialog.getCurrentFocus();
final IBinder windowToken = currentFocus != null ?
currentFocus.getWindowToken() : dialog.getView().getWindowToken();
if (windowToken != null) {
imm.hideSoftInputFromWindow(windowToken, 0);
}
}
}
示例5: initFilenameInputDialog
import com.afollestad.materialdialogs.MaterialDialog; //导入方法依赖的package包/类
public static void initFilenameInputDialog(MaterialDialog show) {
final EditText editText = show.getInputEditText();
editText.setSingleLine();
editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
// create an initial filename to suggest to the user
String filename = createLogFilename();
editText.setText(filename);
// highlight everything but the .txt at the end
editText.setSelection(0, filename.length() - 4);
}