Java Code Examples for android.widget.EditText#setMovementMethod()

The following examples show how to use android.widget.EditText#setMovementMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongolInputMethodManager.java    From mongol-library with MIT License 6 votes vote down vote up
private void setAllowSystemKeyboardOnEditText(EditText editText, boolean allowSystemKeyboard) {
    // TODO this needs to be tested on lower versions!
    // https://stackoverflow.com/a/45229457

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // api 21+
        editText.setShowSoftInputOnFocus(allowSystemKeyboard);
    } else { // api 11+
        if (allowSystemKeyboard) {
            // re-enable keyboard (see https://stackoverflow.com/a/45228867)
            // FIXME this does not necessarily always work
            editText.setTextIsSelectable(false);
            editText.setFocusable(true);
            editText.setFocusableInTouchMode(true);
            editText.setClickable(true);
            editText.setLongClickable(true);
            editText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
            editText.setText(editText.getText(), TextView.BufferType.SPANNABLE);
        } else {
            // disable keyboard
            editText.setTextIsSelectable(true);
        }
    }
}
 
Example 2
Source File: MetadataActivity.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
	
	super.onResume();
	
	try
	{
		boolean signData = false;
		IMedia media = informaCam.mediaManifest.getById(getIntent().getStringExtra(Codes.Extras.EDIT_MEDIA));
		String j3m = ((IMedia) media).buildJ3M(this, signData, null);
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		JsonParser jp = new JsonParser();
		JsonElement je = jp.parse(j3m);
		String prettyJsonString = gson.toJson(je);
		
		EditText txtView = (EditText)findViewById(R.id.textarea_metadata);
		txtView.setText(prettyJsonString);
		
		txtView.setMovementMethod(new ScrollingMovementMethod());
	}
	catch (Exception e)
	{
		finish();
	}
}
 
Example 3
Source File: DetailFragment.java    From kolabnotes-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initTextEditor() {
    boolean useRicheditor = Utils.getUseRicheditor(activity);

    if(useRicheditor) {
        editor = (KolabNotesRichEditor) activity.findViewById(R.id.detail_description);
        editor.setVisibility(View.VISIBLE);
        editor.setBackgroundColor(Color.TRANSPARENT);
        editor.setEditorHeight(300);
        editor.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                final View bar = activity.findViewById(R.id.editor_bar);
                final int visibility = bar.getVisibility();
                if (visibility == View.GONE) {
                    bar.setVisibility(View.VISIBLE);
                } else {
                    bar.setVisibility(View.GONE
                    );
                }
            }
        });
        initEditor();
    }else{
        editText = (EditText) activity.findViewById(R.id.detail_description_plain);
        editText.setVisibility(View.VISIBLE);
        editText.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
 
Example 4
Source File: BblContentFragment.java    From BubbleAlert with MIT License 4 votes vote down vote up
@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());
    }

}