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


Java EditText.setMaxLines方法代码示例

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


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

示例1: setupEditNoteDialog

import android.widget.EditText; //导入方法依赖的package包/类
private void setupEditNoteDialog() {
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PopupActivity.this);
        LayoutInflater inflater = PopupActivity.this.getLayoutInflater();
        final View dialogView = inflater.inflate(R.layout.dialog_edit_note, null);
        dialogBuilder.setView(dialogView);

        final EditText edt = (EditText) dialogView.findViewById(R.id.edit_note);
        edt.setHorizontallyScrolling(false);
        edt.setMaxLines(4);
        edt.setText(mNoteEditedByUser);
        edt.setSelection(mNoteEditedByUser.length());
        dialogBuilder.setTitle(R.string.dialog_note);
        //dialogBuilder.setMessage("输入笔记");
        dialogBuilder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                mNoteEditedByUser = edt.getText().toString();
            }
        });
//                        dialogBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
//                            public void onClick(DialogInterface dialog, int whichButton) {
//                                //pass
//                            }
//                        });
        AlertDialog b = dialogBuilder.create();
        b.show();
    }
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:27,代码来源:PopupActivity.java

示例2: 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

示例3: 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

示例4: onCreateView

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

    directoryInputLayout = (TextInputLayout) view.findViewById(R.id.fragment_repo_directory_input_layout);

    mUriView = (EditText) view.findViewById(R.id.fragment_repo_directory);

    // Not working when done in XML
    mUriView.setHorizontallyScrolling(false);
    mUriView.setMaxLines(3);

    mUriView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            save();
            return true;
        }
    });

    MiscUtils.clearErrorOnTextChange(mUriView, directoryInputLayout);

    view.findViewById(R.id.fragment_repo_directory_browse_button)
            .setOnClickListener(v -> onOpenBrowser());

    if (savedInstanceState == null && TextUtils.isEmpty(mUriView.getText()) && mSelectedUri == null) {
        setFromArgument();
    }

    return view;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:32,代码来源:DirectoryRepoFragment.java

示例5: onViewCreated

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    clickHandler = new ClickHandler(this);

    txtDialogTitle = (TextView) view.findViewById(R.id.txtDialogTitle);
    txtContent = (TextView) view.findViewById(R.id.txtContent);
    btnOk = (TextView) view.findViewById(R.id.btnOk);
    btnExit = (TextView) view.findViewById(R.id.btnExit);
    btnCancel = (TextView) view.findViewById(R.id.btnCancel);
    edtLibName = (EditText) view.findViewById(R.id.edtLibName);

    btnOk.setOnClickListener(clickHandler);
    btnExit.setOnClickListener(clickHandler);
    btnCancel.setOnClickListener(clickHandler);

    txtContent.setText(content);
    btnOk.setText(ok);
    btnCancel.setText(cancel);
    btnExit.setText(exit);
    if (!TextUtils.isEmpty(sDialogTitle)) {
        txtDialogTitle.setText(sDialogTitle);
    }

    if (btnCount == 1) {
        btnCancel.setVisibility(View.GONE);
    } else if (btnCount == 3) {
        btnExit.setVisibility(View.VISIBLE);
    }

    int visibility = hasEditText ? View.VISIBLE : View.GONE;

    edtLibName.setVisibility(visibility);
    if (!TextUtils.isEmpty(textContent)) {

        edtLibName.setText(textContent);
    }

    if (!TextUtils.isEmpty(hintText)) {

        edtLibName.setHint(hintText);
    }

    if (isMultiLineEditText) {
        edtLibName.setMaxLines(1);
        edtLibName.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        edtLibName.setScroller(new Scroller(getContext()));
        edtLibName.setVerticalScrollBarEnabled(true);
        edtLibName.setMovementMethod(new ScrollingMovementMethod());
    }

}
 
开发者ID:nidhinvv,项目名称:BubbleAlert,代码行数:53,代码来源:BblContentFragment.java

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