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


Java EditText.setSingleLine方法代码示例

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


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

示例1: getEditTextDialog

import android.widget.EditText; //导入方法依赖的package包/类
public AlertDialog getEditTextDialog(Context context, String title, final OnClickOkBtnListener mOnClickOkBtnListener) {
    this.mContext = context;
    et = (EditText) LayoutInflater.from(context).inflate(R.layout.layout_edittext, null);
    et.setSingleLine(true);
    AlertDialog mAlertDialog = new AlertDialog.Builder(mContext).setTitle(title)
            .setView(et)
            .setPositiveButton(mContext.getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String input = et.getText().toString();
                    if (null != mOnClickOkBtnListener) {
                        mOnClickOkBtnListener.onClickOk(input);
                    }

                }
            })
            .setNegativeButton(mContext.getString(R.string.cancel), null).show();
    Button btn1 = mAlertDialog.getButton(mAlertDialog.BUTTON_POSITIVE);
    btn1.setTextColor(context.getResources().getColor(R.color.colorPrimary));
    Button btn2 = mAlertDialog.getButton(mAlertDialog.BUTTON_NEGATIVE);
    btn2.setTextColor(context.getResources().getColor(R.color.colorPrimary));
    return mAlertDialog;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:23,代码来源:DialogUtils.java

示例2: initializeSearchMedicineDialog

import android.widget.EditText; //导入方法依赖的package包/类
public void initializeSearchMedicineDialog(final MedicineListActivity medicineListActivity) {
    AlertDialog.Builder searchMedicineDialogBuilder = new AlertDialog.Builder(medicineListActivity);
    searchMedicineDialogBuilder.setTitle(R.string.search_medicine_msg);

    LayoutInflater inflater = (LayoutInflater) medicineListActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.search_medicine, null);

    ImageView voiceInputMedicineNameSearchBtn = (ImageView) view.findViewById(R.id.voice_input_medicine_name_search_btn);
    voiceInputMedicineNameSearchBtn.setOnClickListener(new LaunchVoiceRecognitionOnClickListener(AppConstants.REQUEST_VOICE_INPUT_MEDICINE_NAME));

    searchMedicineEdit = (EditText) view.findViewById(R.id.search_medicine_name_edit);
    searchMedicineEdit.setSingleLine();

    searchMedicineDialogBuilder.setView(view);

    searchMedicineDialogBuilder.setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String searchValue = searchMedicineEdit.getText().toString();

            DbService dbService = SessionManager.getDbService();
            dbService.updateSearchValueInSession(searchValue);
        }
    });

    searchMedicineDialogBuilder.setNegativeButton(R.string.go_back, null);
    searchMedicineDialogBuilder.show();
}
 
开发者ID:lmnpWmi,项目名称:wirtualnaApteczka,代码行数:28,代码来源:SearchMedicineDialogHelper.java

示例3: initializeSearchFamilyMedicineDialog

import android.widget.EditText; //导入方法依赖的package包/类
public void initializeSearchFamilyMedicineDialog(final MedicinesFamilyListTabFragment medicinesFamilyListTabFragment) {
    AlertDialog.Builder searchMedicineDialogBuilder = new AlertDialog.Builder(medicinesFamilyListTabFragment.getContext());
    searchMedicineDialogBuilder.setTitle(R.string.search_medicine_msg);

    LayoutInflater inflater = (LayoutInflater) medicinesFamilyListTabFragment.getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.search_medicine, null);

    ImageView voiceInputMedicineNameSearchBtn = (ImageView) view.findViewById(R.id.voice_input_medicine_name_search_btn);
    voiceInputMedicineNameSearchBtn.setOnClickListener(new LaunchVoiceRecognitionOnClickListener(AppConstants.REQUEST_VOICE_INPUT_MEDICINE_NAME));

    searchMedicineEdit = (EditText) view.findViewById(R.id.search_medicine_name_edit);
    searchMedicineEdit.setSingleLine();

    searchMedicineDialogBuilder.setView(view);

    searchMedicineDialogBuilder.setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String searchValue = searchMedicineEdit.getText().toString();

            DbService dbService = SessionManager.getDbService();
            dbService.updateSearchValueFamilyInSession(searchValue);
        }
    });

    searchMedicineDialogBuilder.setNegativeButton(R.string.go_back, null);
    searchMedicineDialogBuilder.show();
}
 
开发者ID:lmnpWmi,项目名称:wirtualnaApteczka,代码行数:28,代码来源:SearchMedicineDialogHelper.java

示例4: updateTask

import android.widget.EditText; //导入方法依赖的package包/类
private void updateTask(final TaskEntity task) {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(getResources().getString(R.string.title_dialog_update));

    final EditText input = new EditText(this);
    input.setMaxLines(1);
    input.setSingleLine(true);
    String text = (String) task.getTitle();
    input.setText(text);
    alert.setView(input);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

            String currentTimeString = mDateFormatter.format(new Date());

            try {
                task
                        .setTitle(input.getText().toString())
                        .setUpdatedAt(currentTimeString)
                        .save();
            } catch (CouchbaseLiteException e) {
                e.printStackTrace();
            }
        }
    });
    alert.show();
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:29,代码来源:TaskActivity.java

示例5: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContainer = (RelativeLayout) findViewById(R.id.rl_container);
    mEditTextTitle = (EditText) findViewById(R.id.edit_text_title);
    mEditTextContent = (EditText) findViewById(R.id.edit_text_content);
    mButtonClear = (TextView) findViewById(R.id.text_clear);
    mButtonOK = (TextView) findViewById(R.id.text_ok);
    mCheckBoxSelfStarting = (CheckBox) findViewById(R.id.check_box_self_starting);

    mContainer.setOnClickListener(this);
    mButtonOK.setOnClickListener(this);
    mButtonClear.setOnClickListener(this);
    mCheckBoxSelfStarting.setOnClickListener(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mEditTextContent.setSingleLine(false);
        mEditTextContent.setMaxLines(5);
    }

    mContext = getApplicationContext();
    mSharedPreferences = getSharedPreferences(KEY_SETTING, MODE_PRIVATE);

    mEditTextTitle.setText(mSharedPreferences.getString(KEY_TITLE, ""));
    mEditTextContent.setText(mSharedPreferences.getString(KEY_CONTENT, ""));
    mCheckBoxSelfStarting.setChecked(mSharedPreferences.getBoolean(KEY_SELF_STARTING, false));

    Intent intent = getIntent();
    String action = intent.getAction();
    Bundle extras = intent.getExtras();
    if (Intent.ACTION_SEND.equals(action)) {
        if (extras.containsKey(Intent.EXTRA_TEXT)) {
            mEditTextContent.getText().append("\n").append(extras.getString(Intent.EXTRA_TEXT));
        }
    }
}
 
开发者ID:gooosie,项目名称:TinyNoty,代码行数:39,代码来源:MainActivity.java

示例6: renderEditableModeleOfSmartphone

import android.widget.EditText; //导入方法依赖的package包/类
private View renderEditableModeleOfSmartphone(final Smartphone smartphone) {
    final EditText editText = new EditText(getContext());
    editText.setText(smartphone.getModele());
    editText.setPadding(20, 10, 20, 10);
    editText.setTextSize(TEXT_SIZE);
    editText.setSingleLine();
    editText.addTextChangedListener(new SmartphoneModelUpdater(smartphone));
    return editText;
}
 
开发者ID:datalink747,项目名称:Sortable_tableview_soussidev,代码行数:10,代码来源:SmartphoneTableDataAdapter.java

示例7: initFilenameInputDialog

import android.widget.EditText; //导入方法依赖的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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:DialogHelper.java

示例8: initView

import android.widget.EditText; //导入方法依赖的package包/类
private void initView() {
    clearBtn = (Button) findViewById(R.id.btn_clear);
    clearBtn.setOnClickListener(this);
    serviceBtn = (Button) findViewById(R.id.btn_service);
    serviceBtn.setOnClickListener(this);
    bindAliasBtn = (Button) findViewById(R.id.btn_bind_alias);
    bindAliasBtn.setOnClickListener(this);
    unbindAliasBtn = (Button) findViewById(R.id.btn_unbind_alias);
    unbindAliasBtn.setOnClickListener(this);

    btnAddTag = (Button) findViewById(R.id.btnAddTag);
    btnAddTag.setOnClickListener(this);
    btnVersion = (Button) findViewById(R.id.btnVersion);
    btnVersion.setOnClickListener(this);
    btnSilentime = (Button) findViewById(R.id.btnSilentime);
    btnSilentime.setOnClickListener(this);
    btnGetCid = (Button) findViewById(R.id.btnGetCid);
    btnGetCid.setOnClickListener(this);

    tView = (TextView) findViewById(R.id.tvclientid);
    appKeyView = (TextView) findViewById(R.id.tvappkey);
    appSecretView = (TextView) findViewById(R.id.tvappsecret);
    masterSecretView = (TextView) findViewById(R.id.tvmastersecret);
    appIdView = (TextView) findViewById(R.id.tvappid);
    tLogView = (EditText) findViewById(R.id.tvlog);
    tLogView.setInputType(InputType.TYPE_NULL);
    tLogView.setSingleLine(false);
    tLogView.setHorizontallyScrolling(false);
    transmissionBtn = (Button) findViewById(R.id.btn_pmsg);
    transmissionBtn.setOnClickListener(this);
    notifactionBtn = (Button) findViewById(R.id.btn_psmsg);
    notifactionBtn.setOnClickListener(this);
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:34,代码来源:GetuiSdkDemoActivity.java

示例9: inflateView

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View inflateView(LinearLayout layout, String value) {
	editText = new EditText(context);
	editText.setSingleLine();
	if (value != null) {
		editText.setText(value);
	}
	return inflater.new EditBuilder(layout, editText).withLabel(attribute.name).create();
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:10,代码来源:AttributeView.java

示例10: resetFormFields

import android.widget.EditText; //导入方法依赖的package包/类
private void resetFormFields(int countryCodeIndex, boolean autoFocusFirstField) {
    // Save field text so we can restore it after updating the fields for the current country,
    // and reset mAddressFields.
    String[] fieldText = new String[mAddressFields.length];
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null) {
            fieldText[i] = mAddressFields[i].getEditText().getText().toString();
            mAddressFields[i] = null;
        }
    }

    // Remove all address form fields.
    mWidgetRoot.removeAllViews();

    // Get address fields for the selected country.
    List<AddressUiComponent> fields = mAutofillProfileBridge.getAddressUiComponents(
            mCountryCodes.get(countryCodeIndex),
            mLanguageCodeString);
    if (!mUseSavedProfileLanguage) {
        mLanguageCodeString = mAutofillProfileBridge.getCurrentBestLanguageCode();
    }

    // Create form fields and focus the first field if autoFocusFirstField is true.
    boolean firstField = true;
    for (AddressUiComponent field : fields) {
        CompatibilityTextInputLayout fieldFloatLabel =
                (CompatibilityTextInputLayout) mInflater.inflate(
                        R.layout.preference_address_float_label_layout, mWidgetRoot, false);
        fieldFloatLabel.setHint(field.label);

        EditText fieldEditText = fieldFloatLabel.getEditText();
        fieldEditText.addTextChangedListener(this);
        if (field.id == AddressField.STREET_ADDRESS) {
            fieldEditText.setSingleLine(false);
        }

        mAddressFields[field.id] = fieldFloatLabel;
        mWidgetRoot.addView(fieldFloatLabel);

        if (firstField && autoFocusFirstField) {
            fieldEditText.requestFocus();
            firstField = false;
        }
    }

    // Add back saved field text.
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null && fieldText[i] != null
                && !TextUtils.isEmpty(fieldText[i])) {
            mAddressFields[i].getEditText().setText(fieldText[i]);
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:AutofillProfileEditor.java

示例11: onCreateView

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View V = inflater.inflate(R.layout.fragment_edit, container, false);

    CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    int index = getArguments().getInt("INDEX");
    Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(m.GetRow());
    gridLayout.setColumnCount(m.GetCol());
    for (int i = 0; i < m.GetRow(); i++) {
        for (int j = 0; j < m.GetCol(); j++) {
            EditText editText = new EditText(getContext());
            editText.setId(i * 10 + j);
            editText.setGravity(Gravity.CENTER);
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
                editText.setWidth(ConvertTopx(62));
                editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
                        getBoolean("EXTRA_SMALL_FONT", false)));
            } else {
                editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
                editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
                        PreferenceManager.getDefaultSharedPreferences(getContext()).
                                getBoolean("EXTRA_SMALL_FONT", false)));
            }
            editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
            editText.setSingleLine();
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(editText, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);
    RootView = V;
    return V;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:60,代码来源:EditFragment.java

示例12: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(mResourceId);

	try {
		LinearLayout root = (LinearLayout) findViewById(R.id.easy_edit_dialog_root);
		ViewGroup.LayoutParams params = root.getLayoutParams();
		params.width = (int) ScreenUtil.getDialogWidth();
		root.setLayoutParams(params);

		if (mTitle != null) {
			mTitleTextView = (TextView) findViewById(R.id.easy_dialog_title_text_view);
			mTitleTextView.setText(mTitle);
		}

		if (mMessage != null) {
			mMessageTextView = (TextView) findViewById(R.id.easy_dialog_message_text_view);
			mMessageTextView.setText(mMessage);
			mMessageTextView.setVisibility(View.VISIBLE);
		}

		mEdit = (EditText) findViewById(R.id.easy_alert_dialog_edit_text);
		mLengthTextView = (TextView) findViewById(R.id.edit_text_length);
		// mEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxEditTextLength) });
		mLengthTextView.setVisibility(mShowEditTextLength ? View.VISIBLE : View.GONE);
		if (inputType != -1) {
			mEdit.setInputType(inputType);
		}
		mEdit.addTextChangedListener(new EditTextWatcher(mEdit, mLengthTextView, mMaxEditTextLength,
				mShowEditTextLength));

		if (!TextUtils.isEmpty(mEditHint)) {
			mEdit.setHint(mEditHint);
		}
		if (mMaxLines > 0) {
			mEdit.setMaxLines(mMaxLines);
		}
		if (mSingleLine) {
			mEdit.setSingleLine();
		}

		mPositiveBtn = (Button) findViewById(R.id.easy_dialog_positive_btn);
		if (mPositiveBtnStrResId != 0) {
			mPositiveBtn.setText(mPositiveBtnStrResId);
		}
		mPositiveBtn.setOnClickListener(mPositiveBtnListener);

		mNegativeBtn = (Button) findViewById(R.id.easy_dialog_negative_btn);
		if (mNegativeBtnStrResId != 0) {
			mNegativeBtn.setText(mNegativeBtnStrResId);
		}
		mNegativeBtn.setOnClickListener(mNegativeBtnListener);
		mNegativeBtn.setVisibility(View.VISIBLE);
		findViewById(R.id.easy_dialog_btn_divide_view).setVisibility(View.VISIBLE);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:60,代码来源:EasyEditDialog.java


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