當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。