當前位置: 首頁>>代碼示例>>Java>>正文


Java TextInputEditText.setText方法代碼示例

本文整理匯總了Java中android.support.design.widget.TextInputEditText.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextInputEditText.setText方法的具體用法?Java TextInputEditText.setText怎麽用?Java TextInputEditText.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.design.widget.TextInputEditText的用法示例。


在下文中一共展示了TextInputEditText.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createInput

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private static TextInputLayout createInput(Context context, Field field, Object action) {
    try {
        field.setAccessible(true);
        String name = field.getName();
        Object value = field.get(action);
        String valueStr = value != null ? value.toString() : null;

        TextInputLayout layout = new TextInputLayout(context);
        layout.setHint(name);
        TextInputEditText editText = new TextInputEditText(context);
        editText.setText(valueStr);
        layout.setTag(field);
        layout.addView(editText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        return layout;
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:evant,項目名稱:redux,代碼行數:19,代碼來源:EditActionDialogFragment.java

示例2: onAcademicLoaded

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
public void onAcademicLoaded(Academic loadedAcademic) {
    hideLoading();

    academic = loadedAcademic;
    ImageView imageView = (ImageView) findViewById(R.id.profile_pic_view);
    Glide.with(this).load(academic.getImage()).error(R.drawable.profile).into(imageView);

    TextView nameView = (TextView) findViewById(R.id.name_edit);
    nameView.setText(academic.getName());

    emailView = (TextInputEditText) findViewById(R.id.email_edit);
    emailView.setText(academic.getPublicEmail());

    phoneView = (TextInputEditText) findViewById(R.id.phone_edit);
    phoneView.setText(academic.getPhone());

    bioView = (TextInputEditText) findViewById(R.id.bio_edit);
    bioView.setText(academic.getBio());

    roomView = (TextInputEditText) findViewById(R.id.room_edit);
    roomView.setText(academic.getRoom());
}
 
開發者ID:vycius,項目名稱:NMAkademija,代碼行數:24,代碼來源:EditProfileActivity.java

示例3: onCreate

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_key);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefsEditor = mSharedPreferences.edit();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TextView instructionsTextView = (TextView) findViewById(R.id.key_instructions);
    instructionsTextView.setMovementMethod(LinkMovementMethod.getInstance());

    mAPIKey = (TextInputEditText) findViewById(R.id.input_api_key);

    ImageButton save = (ImageButton) findViewById(R.id.button_save);
    ImageButton delete = (ImageButton) findViewById(R.id.button_delete);

    if (!getApiKeyFromPrefs().isEmpty()) {
        mAPIKey.setText(getApiKeyFromPrefs());
    }

    save.setOnClickListener(this);
    delete.setOnClickListener(this);

}
 
開發者ID:Microsoft,項目名稱:Cognitive-TextAnalytics-Android,代碼行數:27,代碼來源:KeyActivity.java

示例4: setDIYWords

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void setDIYWords(Context context, final SharedPreferences sharedPreferences) {
    String[] words = WordMethod.getStringArray(sharedPreferences.getString(Config.PREFERENCE_DIY_WORDS, Config.DEFAULT_DIY_WORDS), 2);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.diy_words);
    LayoutInflater inflater = LayoutInflater.from(context);
    View mView = inflater.inflate(R.layout.dialog_diy_words_set, (ViewGroup) findViewById(R.id.dialog_layout_diy_words));
    final TextInputEditText edit_spy = mView.findViewById(R.id.edittext_diy_spy_word);
    final TextInputEditText edit_normal = mView.findViewById(R.id.edittext_diy_normal_word);
    edit_spy.setText(words[Config.PLAYER_WORD_SPY]);
    edit_normal.setText(words[Config.PLAYER_WORD_NORMAL]);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String[] result = new String[2];
            result[Config.PLAYER_WORD_NORMAL] = edit_normal.getText().toString();
            result[Config.PLAYER_WORD_SPY] = edit_spy.getText().toString();
            if (result[Config.PLAYER_WORD_NORMAL].replace(" ", "").equals("") || result[Config.PLAYER_WORD_SPY].replace(" ", "").equals("")) {
                CheckBox checkBox_diy = findViewById(R.id.checkbox_diy_words);
                if (checkBox_diy.isChecked()) {
                    checkBox_diy.setChecked(false);
                    sharedPreferences.edit().putBoolean(Config.PREFERENCE_USE_DIY_WORDS, false).apply();
                }
            }
            sharedPreferences.edit().putString(Config.PREFERENCE_DIY_WORDS, Arrays.toString(result)).apply();
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
開發者ID:XFY9326,項目名稱:CatchSpy,代碼行數:31,代碼來源:MainActivity.java

示例5: addNewDictionary

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void addNewDictionary() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_edittext, (ViewGroup) getActivity().findViewById(R.id.layout_dialog_edit_text));
    final TextInputEditText editText = mView.findViewById(R.id.edittext_dialog);
    editText.setHint(R.string.default_new_dictionary_name);
    String name = getString(R.string.default_new_dictionary_name) + "_" + System.currentTimeMillis();
    editText.setText(name);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.settings_extra_words_add);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String result = editText.getText().toString();
            if (result.replace(" ", "").equalsIgnoreCase("")) {
                Toast.makeText(getActivity(), R.string.settings_extra_words_add_error, Toast.LENGTH_SHORT).show();
            } else {
                try {
                    File file = new File(Config.DEFAULT_APPLICATION_DATA_DIR + result);
                    if (!file.exists()) {
                        if (file.createNewFile()) {
                            if (IOMethod.writeFile(new JSONObject().put(Config.DEFAULT_EXTRA_WORDS_DATA_NAME, new JSONArray()).toString(), file.getAbsolutePath())) {
                                String newName = Code.unicodeEncode(result) + "-" + Code.getFileMD5String(file.getAbsolutePath());
                                if (IOMethod.renameFile(file.getAbsolutePath(), newName)) {
                                    editWords(file.getParent() + File.separator + newName, result);
                                    return;
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                Toast.makeText(getActivity(), R.string.settings_extra_words_add_error, Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
開發者ID:XFY9326,項目名稱:CatchSpy,代碼行數:41,代碼來源:ExtraDictionarySettingsFragment.java

示例6: renameDictionary

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void renameDictionary(final String path, String name) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_edittext, (ViewGroup) getActivity().findViewById(R.id.layout_dialog_edit_text));
    final TextInputEditText editText = mView.findViewById(R.id.edittext_dialog);
    editText.setHint(R.string.settings_extra_words_rename_dictionary);
    editText.setText(name);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.settings_extra_words_rename_dictionary);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String result = editText.getText().toString();
            if (result.replace(" ", "").equalsIgnoreCase("")) {
                Toast.makeText(getActivity(), R.string.settings_extra_words_rename_dictionary_failed, Toast.LENGTH_SHORT).show();
            } else {
                if (ExtraWordMethod.renameDictionary(getActivity(), path, result)) {
                    Toast.makeText(getActivity(), R.string.settings_extra_words_rename_dictionary_success, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getActivity(), R.string.settings_extra_words_rename_dictionary_failed, Toast.LENGTH_SHORT).show();
                }
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
開發者ID:XFY9326,項目名稱:CatchSpy,代碼行數:28,代碼來源:ExtraDictionarySettingsFragment.java

示例7: defineObjects

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void defineObjects() {
    message = (TextInputEditText) findViewById(R.id.post_call_text);
    Switch emergency = (Switch) findViewById(R.id.post_call_emergencyswitch);
    String m = user.toUpperCase();
    m += ": ";
    message.setText(m);
    message.requestFocus();
    emergency.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            emergencyBool = isChecked;
        }
    });
}
 
開發者ID:DecentralizedAmateurPagingNetwork,項目名稱:DAPNETApp,代碼行數:15,代碼來源:PostCallActivity.java

示例8: setText

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
/**
 * Binding adapter for converting view position and dimension values to text for EditTexts. The
 * InverseBindingAdapter that follows does the reverse
 * @param view
 * @param dimValue
 */
@BindingAdapter("android:text")
public static void setText(TextInputEditText view, float dimValue) {
    String curString = view.getText().toString();
    int curInt;
    try {
        curInt = Integer.parseInt(curString);
    } catch (NumberFormatException e) {
        curInt = 0;
    }

    // Do not set the text if the parsed string is null, if it ends in a . or if it is equal to
    // the current value to avoid the value changing under the user's cursor (and the cursor
    // jumping) as they type.
    if (curString == null
            || curString.length() == 0
            || curString.charAt(curString.length() - 1) != '.'
            && dimValue != curInt) {

        String dimString = "";
        if (dimValue == (int) dimValue) {
            dimString = Integer.toString((int) dimValue);
        } else {
            dimString = Float.toString(dimValue);
        }

        if (dimString != null && view != null && view.getText() != null &&
                !dimString.equals(view.getText().toString())) {
            view.setText(dimString);
        }
    }
}
 
開發者ID:google,項目名稱:spline,代碼行數:38,代碼來源:LayerBindingAdapters.java

示例9: onCreate

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activityComponent().inject(this);

    forgotPresenter.attachView(this);

    inputEmail = (TextInputEditText) findViewById(R.id.reset_password_email);
    inputEmail.setText(getIntent().getStringExtra(RESET_EMAIL));
    Button resetPassword = (Button) findViewById(R.id.button_reset_password);
    resetPassword.setOnClickListener(view -> resetPassword());
    ViewUtil.hideKeyboard(this);
}
 
開發者ID:Mfrenchy77,項目名稱:HorseandRidersCompanion,代碼行數:14,代碼來源:ForgotActivity.java

示例10: onCreateDialogView

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
public View onCreateDialogView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_user_profile_dialog, container, false);

    // Retrieve the text fields from the view.
    firstNameText = (TextInputEditText) rootView.findViewById(R.id.firstNameText);
    lastNameText = (TextInputEditText) rootView.findViewById(R.id.lastNameText);
    emailText = (TextInputEditText) rootView.findViewById(R.id.emailText);
    streetText = (TextInputEditText) rootView.findViewById(R.id.streetText);
    cityText = (TextInputEditText) rootView.findViewById(R.id.cityText);
    stateText = (TextInputEditText) rootView.findViewById(R.id.stateText);
    zipText = (TextInputEditText) rootView.findViewById(R.id.zipText);
    phoneText = (TextInputEditText) rootView.findViewById(R.id.phoneText);


    // Populate the text fields with the user's profile.
    UserProfile profile = (UserProfile) getArguments().getSerializable(USER_PROFILE_ARG);
    firstNameText.setText(profile.getFirstName());
    lastNameText.setText(profile.getLastName());
    emailText.setText(profile.getEmail());
    streetText.setText(profile.getStreet());
    cityText.setText(profile.getCity());
    stateText.setText(profile.getState());
    zipText.setText(profile.getZip());
    phoneText.setText(profile.getPhone());

    return rootView;
}
 
開發者ID:Date-A-Dog,項目名稱:Date-A-Dog,代碼行數:30,代碼來源:UserProfileDialogFragment.java

示例11: setup

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void setup(Context context, AttributeSet attrs, int defStyleAttr) {
    editText = new TextInputEditText(context);

    if (attrs != null) {
        TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FloatingEditText, 0, 0);

        if (ta.hasValue(R.styleable.FloatingEditText_android_text)) {
            editText.setText(ta.getString(R.styleable.FloatingEditText_android_text));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textAllCaps)) {
            editText.setAllCaps(ta.getBoolean(R.styleable.FloatingEditText_android_textAllCaps, false));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textColor)) {
            editText.setTextColor(ta.getColor(R.styleable.FloatingEditText_android_textColor, 0));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textSize)) {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, ta.getDimensionPixelSize(R.styleable.FloatingEditText_android_textSize, 0));
        }

        int textStyle = Typeface.NORMAL;
        if (ta.hasValue(R.styleable.FloatingEditText_android_textStyle)) {
            textStyle = ta.getInt(R.styleable.FloatingEditText_android_textStyle, Typeface.NORMAL);
        }

        String fontFamily = "sans-serif";
        if (ta.hasValue(R.styleable.FloatingEditText_android_fontFamily)) {
            fontFamily = ta.getString(R.styleable.FloatingEditText_android_fontFamily);
        }

        editText.setTypeface(Typeface.create(fontFamily, textStyle));

        if (ta.hasValue(R.styleable.FloatingEditText_android_inputType)) {
            editText.setInputType(ta.getInt(R.styleable.FloatingEditText_android_inputType, -1));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_imeOptions)) {
            editText.setImeOptions(ta.getInt(R.styleable.FloatingEditText_android_imeOptions, -1));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_maxLength)) {
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(ta.getInt(R.styleable.FloatingEditText_android_maxLength, 0))});
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_maxLines)) {
            editText.setMaxLines(ta.getInt(R.styleable.FloatingEditText_android_maxLines,1));
        }

        ta.recycle();
    }

    addView(editText);
}
 
開發者ID:rafakob,項目名稱:FloatingEditText,代碼行數:56,代碼來源:FloatingEditText.java

示例12: onCreateDialog

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    this.mContact = getArguments().getParcelable("contact");

    materialDialog = new MaterialDialog.Builder(getActivity())
            .title(mContact==null ? "Add Contact" : "Edit Contact")
            .customView(R.layout.dialog_add_contact, true)
            .cancelable(false)
            .positiveText(mContact==null ? R.string.add : R.string.update)
            .negativeText(android.R.string.cancel)
            .build();

    positiveAction = materialDialog.getActionButton(DialogAction.POSITIVE);
    negativeAction = materialDialog.getActionButton(DialogAction.NEGATIVE);
    nameEditText = (TextInputEditText) materialDialog.getCustomView().findViewById(R.id.edit_name);
    mobileEditText = (TextInputEditText) materialDialog.getCustomView().findViewById(R.id.edit_mobile);
    nameInputLayout = (TextInputLayout) materialDialog.getCustomView().findViewById(R.id.input_layout_name);
    mobileInputLayout = (TextInputLayout) materialDialog.getCustomView().findViewById(R.id.input_layout_mobile);

    if(mContact!=null) {
        nameEditText.setText(mContact.getName());
        mobileEditText.setText(mContact.getMobile());
    }

    positiveAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            nameInputLayout.setErrorEnabled(false);
            nameInputLayout.setError(null);

            mobileInputLayout.setErrorEnabled(false);
            mobileInputLayout.setError(null);

            String name = nameEditText.getText().toString().trim();
            String mobile = mobileEditText.getText().toString().trim();

            if(mobile.isEmpty()){
                mobileInputLayout.setError("Please enter mobile");
                return;
            }

            if(mDialogCallback!=null) {

                if(mContact==null) {
                    mContact = new Contact();
                    mContact.setName(name);
                    mContact.setMobile(mobile);
                    mDialogCallback.onContactAdded(mContact);
                }
                else {
                    mContact.setName(name);
                    mContact.setMobile(mobile);
                    mDialogCallback.onContactUpdated(mContact);
                }

                dismiss();
            }

        }
    });

    return materialDialog;
}
 
開發者ID:squareboat,項目名稱:Excuser,代碼行數:67,代碼來源:AddContactDialog.java

示例13: onCreateDialog

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_edit_host,
            (ViewGroup) getActivity().getWindow().getDecorView(), false);
    mTitle = (TextInputEditText) view.findViewById(R.id.et_title);
    mVeid = (TextInputEditText) view.findViewById(R.id.et_veid);
    mKey = (TextInputEditText) view.findViewById(R.id.et_key);
    mLayoutTitle = (TextInputLayout) view.findViewById(R.id.til_title);
    mLayoutVeid = (TextInputLayout) view.findViewById(R.id.til_veid);
    mLayoutKey = (TextInputLayout) view.findViewById(R.id.til_key);

    final Bundle args = getArguments();
    if (args != null) {
        mHost = args.getParcelable(Constants.EXTRA_KEY_HOST);
        if (mHost != null) {
            mTitle.setText(mHost.title);
            mVeid.setText(mHost.veid);
            mKey.setText(mHost.key);
            mTitle.setSelection(mHost.title.length());
        }
    } else {
        mHost = new Host();
    }

    mDialog = new AlertDialog.Builder(getActivity())
            .setView(view)
            .setTitle(args == null
                    ? getString(R.string.dialog_title_add_host)
                    : getString(R.string.dialog_title_update_host))
            .setPositiveButton(args == null
                    ? getString(R.string.dialog_button_ok)
                    : getString(R.string.dialog_button_update), null)
            .setNegativeButton(getString(R.string.dialog_button_cancel), null)
            .setOnKeyListener((dialog, keyCode, event) -> {
                if (keyCode == KeyEvent.KEYCODE_BACK
                        && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
                    dialog.dismiss();
                    return true;
                }
                return false;
            }).create();
    mDialog.setOnShowListener(dialog -> {
        mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
            if (mTitle.length() == 0 || mVeid.length() == 0 || mKey.length() == 0) {
                fixEditTextInput();
            } else {
                mHost.title = mTitle.getText().toString();
                mHost.veid = mVeid.getText().toString();
                mHost.key = mKey.getText().toString();
                dispatchProcess(mHost);
                dialog.dismiss();
            }
        });
        mMainView.hideFab();
    });
    return mDialog;
}
 
開發者ID:pexcn,項目名稱:BandwagonHost,代碼行數:59,代碼來源:HostDialogFragment.java

示例14: initializeCreate

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void initializeCreate(View view) {
    levelName = (TextInputEditText) view.findViewById(R.id.item_name);
    learningLevelDescription = (TextInputEditText) view.findViewById(R.id.level_create_description_learning);
    completeLevelDescription = (TextInputEditText) view.findViewById(R.id.level_create_description_complete);
    learningLevelDescription.setVisibility(View.VISIBLE);
    completeLevelDescription.setVisibility(View.VISIBLE);
    TextInputEditText description1 = (TextInputEditText) view.findViewById(R.id.item_description);
    description1.setVisibility(View.GONE);
    TextView dialogTitle = (TextView) view.findViewById(R.id.dialog_title);
    dialogTitle.setText(tag.equals(EDIT_LEVEL) ? "Edit Level" : "Create New Level");

    ImageButton deleteButton = (ImageButton) view.findViewById(R.id.delete_item_button);
    deleteButton.setVisibility(tag.equals(EDIT_LEVEL) ? View.VISIBLE : View.GONE);
    deleteButton.setOnClickListener(view1 -> {
        if (level.getId() != null) {
            BusProvider.getBusProviderInstance().post(new LevelDeleteEvent(level.getId()));
            dismiss();
        } else {
            Timber.d("Delete Level Error:  name is null");
        }
    });

    //setup Edit Level text
    if (tag.equals(EDIT_LEVEL)) {
        levelName.setText(level.getLevelName());
        learningLevelDescription.setText(level.getLearningDescription());
        completeLevelDescription.setText(level.getCompleteDescription());
    }

    LinearLayout createButton = (LinearLayout) view.findViewById(R.id.accept_button);


    //----Create/Edit Level if fields are not empty
    createButton.setOnClickListener(v -> {
        String name = levelName.getText().toString().trim();
        String learningDescription = learningLevelDescription.getText().toString().trim();
        String completeDescription = completeLevelDescription.getText().toString().trim();

        Level newLevel = new Level();
        newLevel.setLevelName(name);
        newLevel.setId(tag.equals(EDIT_LEVEL) ? level.getId() : ViewUtil.createId());
        newLevel.setLearningDescription(learningLevelDescription.getText().toString().trim());
        newLevel.setCompleteDescription(completeLevelDescription.getText().toString().trim());
        newLevel.setSkillId(skillId);
        newLevel.setLastEditBy(AccountManager.currentUser());
        newLevel.setLastEditDate(System.currentTimeMillis());

        if (!TextUtils.isEmpty(name) ||
                !TextUtils.isEmpty(learningDescription) ||
                !TextUtils.isEmpty(completeDescription)) {
            BusProvider.getBusProviderInstance().post(new LevelCreateEvent(newLevel, tag.equals(EDIT_LEVEL)));
            dismiss();
        } else {
            Toast.makeText(getActivity(), "Fields must not be left blank", Toast.LENGTH_SHORT).show();
        }
    });

    LinearLayout cancelButton = (LinearLayout) view.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(v -> dismiss());
}
 
開發者ID:Mfrenchy77,項目名稱:HorseandRidersCompanion,代碼行數:61,代碼來源:DialogCreateAdjustLevel.java

示例15: onCreateDialog

import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final LayoutInflater inflater = getActivity().getLayoutInflater();
    final FrameLayout fl = new FrameLayout(getActivity());
    final View view = inflater.inflate(R.layout.dialog_create_skill_tree_item, fl, false);
    fl.addView(view);

    categoryName = (TextInputEditText) view.findViewById(R.id.item_name);
    categoryDescription = (TextInputEditText) view.findViewById(R.id.item_description);

    TextView dialogTitle = (TextView) view.findViewById(R.id.dialog_title);
    dialogTitle.setText(tag.equals(EDIT_CATEGORY) ? "Edit Category" : "Create New Category");

    ImageButton deleteButton = (ImageButton) view.findViewById(R.id.delete_item_button);
    deleteButton.setVisibility(tag.equals(EDIT_CATEGORY) ? View.VISIBLE : View.GONE);
    deleteButton.setOnClickListener(view1 -> {
        if (category.getName() != null) {
            BusProvider.getBusProviderInstance().post(new CategoryDeleteEvent(category.getName()));
            dismiss();
        } else {
            Timber.d("DeleteCategory Error:  name is null");
        }
    });

    //Edit Category
    if (tag.equals(EDIT_CATEGORY)) {
        categoryName.setText(category.getName());
        categoryDescription.setText(category.getDescription());
    }

    LinearLayout createButton = (LinearLayout) view.findViewById(R.id.accept_button);
    createButton.setOnClickListener(v -> {
        String name = categoryName.getText().toString().trim();
        String description = categoryDescription.getText().toString().trim();

        if (!TextUtils.isEmpty(name) || !TextUtils.isEmpty(description)) {
            BusProvider.getBusProviderInstance().post(new CategoryCreateEvent(description, name));
            dismiss();
        } else {
            Toast.makeText(getActivity(), "Fields must not be left blank", Toast.LENGTH_SHORT).show();
        }
    });

    LinearLayout cancelButton = (LinearLayout) view.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(v -> dismiss());
    builder.setView(fl);
    AlertDialog dialog = builder.create();
    BusProvider.getBusProviderInstance().register(this);

    dialog.getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    dialog.show();

    return dialog;
}
 
開發者ID:Mfrenchy77,項目名稱:HorseandRidersCompanion,代碼行數:57,代碼來源:DialogCreateCategory.java


注:本文中的android.support.design.widget.TextInputEditText.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。