当前位置: 首页>>代码示例>>Java>>正文


Java EditText.setHint方法代码示例

本文整理汇总了Java中android.widget.EditText.setHint方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setHint方法的具体用法?Java EditText.setHint怎么用?Java EditText.setHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.setHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeResources

import android.widget.EditText; //导入方法依赖的package包/类
private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.centered_app_title);

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);

  showButton       = (ImageButton)     findViewById(R.id.passphrase_visibility);
  hideButton       = (ImageButton)     findViewById(R.id.passphrase_visibility_off);
  visibilityToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
  passphraseText   = (EditText)        findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString("  " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
  hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  showButton.setOnClickListener(new ShowButtonOnClickListener());
  hideButton.setOnClickListener(new HideButtonOnClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:23,代码来源:PassphrasePromptActivity.java

示例2: onClick

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    EditTextSetting entry = getEntry();
    View view = LayoutInflater.from(v.getContext()).inflate(R.layout.dialog_edit_text, null);
    EditText text = view.findViewById(R.id.edit_text);
    text.setText(entry.mText);
    text.setHint(entry.mDefaultText);
    new ThemedAlertDialog.Builder(v.getContext())
            .setTitle(entry.mName)
            .setView(view)
            .setPositiveButton(R.string.action_ok, (DialogInterface di, int i) -> {
                entry.setText(text.getText().toString());
            })
            .setNegativeButton(R.string.action_cancel, null)
            .show();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:17,代码来源:EditTextSetting.java

示例3: initView

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 绑定搜索框xml视图
 */
private void initView() {
    // 1. 绑定R.layout.search_layout作为搜索框的xml文件
    LayoutInflater.from(mContext).inflate(R.layout.search_layout,this);
    et_search = (EditText) findViewById(R.id.et_search);
    et_search.setTextSize(textSizeSearch);
    et_search.setTextColor(textColorSearch);
    et_search.setHint(textHintSearch);

    // 3. 搜索框背景颜色
    search_block = (LinearLayout) findViewById(R.id.search_linear);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) search_block.getLayoutParams();
    params.height = searchBlockHeight;
    search_block.setBackgroundColor(searchBlockColor);
    search_block.setLayoutParams(params);

    // 4. 历史搜索记录 = ListView显示
    listView = (SearchListView) findViewById(R.id.listView);

    // 5. 删除历史搜索记录 按钮
    tv_clear = (TextView) findViewById(R.id.tv_clear);
    tv_clear.setVisibility(INVISIBLE);

    // 6. 返回按键
    searchBack = (ImageView) findViewById(R.id.search_icon);
}
 
开发者ID:AndroidBoySC,项目名称:Mybilibili,代码行数:29,代码来源:MySearchView.java

示例4: promptNew

import android.widget.EditText; //导入方法依赖的package包/类
private void promptNew() {

        final EditText tag = new EditText(this);
        tag.setHint(R.string.opt_name);

        AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .setTitle(R.string.new_backup)
                .setView(tag)
                .setPositiveButton(R.string.take_backup, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        newBackup(tag.getText().toString());
                    }
                }).setNegativeButton(R.string.cancel, null);
        builder.show();
    }
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:17,代码来源:BackupActivity.java

示例5: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    callId = intent.getStringExtra("callId");
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(20, 20, 20, 20);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    editText = new EditText(this);
    editText.setHint(R.string.demo_b_username_hint);
    editText.setText("billy");
    layout.addView(editText, params);
    Button button = new Button(this);
    button.setText(R.string.demo_b_click_login);
    button.setOnClickListener(this);
    layout.addView(button, params);
    setContentView(layout);
}
 
开发者ID:luckybilly,项目名称:CC,代码行数:20,代码来源:LoginActivity.java

示例6: addEdit

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * Adds the new edit to the list with id, text and hint
 **/
public DialogBuilder addEdit(int id, String text, String hint) {
    // inflate row using default layout
    LayoutInflater inflater = LayoutInflater.from(context);
    View itemView = inflater.inflate(R.layout.row_edit_dialog, null);
    // if there are some rows above
    if (listLayout.getChildCount() > 0) {
        // show top border
        View borderView = itemView.findViewById(R.id.item_top_border);
        if (borderView != null) {
            borderView.setVisibility(View.VISIBLE);
        }
    }
    // setup edit
    EditText editText = (EditText) itemView.findViewById(R.id.edit_text);
    editText.setText(text);
    editText.setSelection(editText.getText().length());
    editText.setHint(hint);
    editText.setId(id);

    return addItem(itemView);
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:25,代码来源:DialogBuilder.java

示例7: onBuildContent

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);
    layout.setPadding(padding, padding, padding, padding);
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("输入框");
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);
    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
    textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
            "QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
            "同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
            "不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);
    return layout;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:26,代码来源:QDDialogFragment.java

示例8: popup_show

import android.widget.EditText; //导入方法依赖的package包/类
/**CUSTOMIZEABLE pop up input text for positive button (right button) and negative button (left button)*/
public void popup_show(String popup_title, String popup_hint, DialogInterface.OnClickListener positiveOCL,DialogInterface.OnClickListener negativeOCL, String positiveText, String negativeText)
{
    //build popup dialogue
    popUpWindow = new AlertDialog.Builder(context);
    popUpWindow.setTitle(popup_title);

    //set up the input field
    popup_inputText = new EditText(context);
    popup_inputText.setInputType(InputType.TYPE_CLASS_TEXT);
    popup_inputText.setHint(popup_hint); //set hint on what value the user should enter
    popUpWindow.setView(popup_inputText);

    //set up positive button
    popUpWindow.setPositiveButton(positiveText, positiveOCL);

    //set up negative button
    popUpWindow.setNegativeButton(negativeText, negativeOCL);

    popUpWindow.show();
}
 
开发者ID:FYP17-4G,项目名称:Aardvark,代码行数:22,代码来源:App_Framework.java

示例9: setEditViewsName

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 设置编辑列表VIEW
 *
 * @param names 编辑view 的name
 * @return this
 */
public BaseDialog setEditViewsName(List<String> names) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String name :
                names) {
                TextView textView = new TextView(getContext());
                textView.setText(name);
                EditText editText = new EditText(getContext());
                editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
                editText.setHint("请输入" + name);
                editText.setPadding(10, 0, 0, 0);
                editText.setHintTextColor(Color.BLUE);
                LinearLayout child = new LinearLayout(getContext());
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                child.setOrientation(LinearLayout.HORIZONTAL);
                child.setGravity(Gravity.CENTER_VERTICAL);
                child.setLayoutParams(params);
                child.addView(textView);
                child.addView(editText);
                middleLayout.addView(child);
        }
        return this;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:31,代码来源:BaseDialog.java

示例10: setHint

import android.widget.EditText; //导入方法依赖的package包/类
@BindingAdapter("judgehint")
public static void setHint(EditText view, CharSequence hint) {
    switch (view.getId()) {
        case R.id.edit_options_logcat:
            String options = "[options]";
            if (!hint.equals("")) {
                options = hint.toString();
            }
            view.setHint(options);
            break;
        case R.id.edit_filter_logcat:
            String filter = "[filterspecs]";
            if (!hint.equals("")) {
                filter = hint.toString();
            }
            view.setHint(filter);
            break;
        case R.id.edit_grep_logcat:
            String grep = "[grep]";
            if (!hint.equals("")) {
                grep = hint.toString();
            }
            view.setHint(grep);
            break;
        default:
            ZLog.e("no match");
            break;
    }
}
 
开发者ID:Zane96,项目名称:Fairy,代码行数:30,代码来源:EditBindingAdapter.java

示例11: createEditText

import android.widget.EditText; //导入方法依赖的package包/类
private EditText createEditText() {
	LinearLayout.LayoutParams EditTextlayoutParams = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	EditText editText = new EditText(getContext());
	editText.setLayoutParams(EditTextlayoutParams);
	editText.setHint(getString(R.string.answer, letters[inputLayout.getChildCount()]));
	editText.setInputType(InputType.TYPE_CLASS_TEXT);
	return editText;
}
 
开发者ID:Komdosh,项目名称:SocEltech,代码行数:10,代码来源:QuestionFragment.java

示例12: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    usernameField = new EditText(this);
    passwordField = new EditText(this);
    usernameField.setHint("Username");
    passwordField.setHint("Password");
    usernameField.setText("user");
    passwordField.setText("passwd2");
    customFieldsLayout.addView(usernameField);
    customFieldsLayout.addView(passwordField);
}
 
开发者ID:Vorlonsoft,项目名称:AndroidAsyncHTTP,代码行数:13,代码来源:DigestAuthSample.java

示例13: onItemSelected

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if (locations.get(position).equals(getResources().getStringArray(R.array.locations)[3])) {
        // add custom location
        final EditText editText = new EditText(this);
        DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == DialogInterface.BUTTON_POSITIVE) {
                    String location = editText.getText().toString();
                    if (!TextUtils.isEmpty(location)) {
                        locations.add(locations.size() - 1, location);
                        adapter.notifyDataSetChanged();
                        spinner.setSelection(locations.size() - 2);
                        return;
                    } else {
                        spinner.setSelection(0);
                        Toast.makeText(getApplicationContext(), getString(R.string.incorrect_installation_location), Toast.LENGTH_SHORT).show();
                    }
                }
                spinner.setSelection(0);
            }
        };
        editText.setHint(R.string.install_location);
        new AlertDialog.Builder(this).setCancelable(false)
                .setView(editText)
                .setNeutralButton(android.R.string.cancel, onClickListener)
                .setPositiveButton(android.R.string.ok, onClickListener)
                .show();
    }
}
 
开发者ID:Crixec,项目名称:ADBToolKitsInstaller,代码行数:32,代码来源:MainActivity.java

示例14: showInputedError

import android.widget.EditText; //导入方法依赖的package包/类
/**字符不合法提示(et == null ? toast : hint)
 * @param context
 * @param et
 * @param string
 * @return
 */
public static boolean showInputedError(Activity context, EditText et, String string) {
	if (context == null || StringUtil.isNotEmpty(string, false) == false) {
		Log.e(TAG, "showInputedError  context == null || et == null || StringUtil.isNotEmpty(string, false) == false >> return false;");
		return false;
	}
	if (et == null) {
		Toast.makeText(context, StringUtil.getTrimedString(string), Toast.LENGTH_SHORT).show();
	} else {
		et.setText("");
		et.setHint(string);
		et.setHintTextColor(context.getResources().getColor(R.color.red));
	}
	return false;
}
 
开发者ID:TommyLemon,项目名称:APIJSON-Android-RxJava,代码行数:21,代码来源:EditTextUtil.java

示例15: showProxyUrlInputDialog

import android.widget.EditText; //导入方法依赖的package包/类
private void showProxyUrlInputDialog() {
    final EditText editText = new EditText(this);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    editText.setHint(getString(R.string.config_url_hint));
    editText.setText(readProxyUrl());

    new AlertDialog.Builder(this)
            .setTitle(R.string.config_url)
            .setView(editText)
            .setPositiveButton(R.string.btn_ok, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (editText.getText() == null) {
                        return;
                    }

                    String ProxyUrl = editText.getText().toString().trim();
                    if (isValidUrl(ProxyUrl)) {
                        setProxyUrl(ProxyUrl);
                        textViewProxyUrl.setText(ProxyUrl);
                    } else {
                        Toast.makeText(MainActivity.this, R.string.err_invalid_url, Toast.LENGTH_SHORT).show();
                    }
                }
            })
            .setNegativeButton(R.string.btn_cancel, null)
            .show();
}
 
开发者ID:IronMan001,项目名称:ss-android,代码行数:29,代码来源:MainActivity.java


注:本文中的android.widget.EditText.setHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。