Example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Prototype

int IME_ACTION_DONE

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "done" operation, typically meaning there is nothing more to input and the IME will be closed.

Usage

From source file:com.crimsonrgames.titanium.htmltester.AddTagDialogFragment.java

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId) {
        // Return input text to activity
        OnAddTagDialogFragmentInteractionListener activity = (OnAddTagDialogFragmentInteractionListener) getActivity();
        activity.onFinishTagEditDialog(mEditText.getText().toString());
        this.dismiss();
        return true;
    }//from  w  w  w  .  ja va 2 s.  c o m
    return false;
}

From source file:org.totschnig.myexpenses.dialog.EditTextDialog.java

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId
            || (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN)) {
        // Return input text to activity
        EditTextDialogListener activity = (EditTextDialogListener) getActivity();
        Bundle args = getArguments();//from  w  w w .j  av a  2 s.  c om
        String result = mEditText.getText().toString();
        if (result.equals(""))
            Toast.makeText(getActivity(), getString(R.string.no_title_given), Toast.LENGTH_LONG).show();
        else {
            args.putString("result", result);
            activity.onFinishEditDialog(args);
            this.dismiss();
            return true;
        }
    }
    return false;
}

From source file:org.lunci.dumbthing.dialog.AddDumbThingDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.dialog_add_dumb_thing, container);
    mEditText = (EditText) view.findViewById(R.id.editText_content);
    if (savedInstanceState != null) {
        mEditText.setText(savedInstanceState.getString(EXTRA_CONTENT));
    } else if (PreferencesTracker.getInstance().isEnableAutoPrefix()) {
        mEditText.setText("");
        mEditText.append(PreferencesTracker.getInstance().getPrefix());
    }//from   w w w.ja  v  a2 s  .c o  m
    mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (EditorInfo.IME_ACTION_DONE == actionId) {
                EventBus.getDefault().post(new AddDumbThingDialogCallback(mEditText.getText().toString()));
                dismiss();
                return true;
            }
            return false;
        }
    });
    view.findViewById(R.id.button_positive).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EventBus.getDefault().post(new AddDumbThingDialogCallback(mEditText.getText().toString()));
            dismiss();
        }
    });
    view.findViewById(R.id.button_negative).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    return view;
}

From source file:pocheng.cs125.project.simplescada.SearchKeywordFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.search_keyword_fragment, container, false);
    final TextView textView_one = (TextView) rootView.findViewById(R.id.textView1);
    final EditText areaEditText = (EditText) rootView.findViewById(R.id.area_editText);
    areaEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*  w w  w.j  a  v a 2s .  co  m*/
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            boolean handled = false;
            if (i == EditorInfo.IME_ACTION_NEXT) {
                textView_one.setText("");
                areaInput = textView.getText().toString();
                if (areaInput.equals("")) {
                    areaInput = "empty";
                    handled = true;
                }
            }
            return handled;
        }
    });
    EditText deviceEditText = (EditText) rootView.findViewById(R.id.device_editText);
    deviceEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                deviceInput = textView.getText().toString();
                if (deviceInput.equals("")) {
                    deviceInput = "empty";
                }
            }
            return false;
        }
    });
    Button searchButton = (Button) rootView.findViewById(R.id.search_button);
    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isEmpty(areaEditText)) {
                textView_one.setText(R.string.area_empty_warning);
            } else if (areaInput.equals("empty")) {
                textView_one.setText(R.string.area_assign_warning);
            } else {
                textView_one.setText("");
                Keyword keyword = new Keyword(areaInput, deviceInput);
                Intent intent = new Intent(getActivity(), SearchResultsActivity.class);
                intent.putExtra("keyword", keyword);
                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:net.thetabx.gcd.activity.ChatActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);
    header = (TextView) findViewById(R.id.txt_chat_header);
    listView = (ListView) findViewById(R.id.lview_chat);
    swipe = (SwipeRefreshLayout) findViewById(R.id.swipe_chat);
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override/*from w ww  .  j a  v a2  s.  c o m*/
        public void onRefresh() {
            fetchFreshData();
        }
    });
    edit = (EditText) findViewById(R.id.etxt_chat_send);
    edit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE
                    || event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                header.setText(String.format("Sent %s", v.getText()));
                sendChatMessage(v);
                //v.setText("");
                fetchFreshData();
            }
            return false;
        }
    });

    header.setText("Start");
    if (messages == null) {
        fetchFreshData();
    } else
        fillActivity();
}

From source file:dev.drsoran.moloko.util.UIUtils.java

public final static boolean hasInputCommitted(int actionId) {
    return actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
            || actionId == EditorInfo.IME_NULL;
}

From source file:ch.jeda.platform.android.InputDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
    builder.setTitle(this.request.getTitle());
    builder.setMessage(this.request.getMessage());
    this.input = new EditText(this.getActivity());
    // This is required in order to show soft keyboard when input is focused.
    this.input.setFocusableInTouchMode(true);
    this.input.setImeOptions(EditorInfo.IME_ACTION_DONE);
    this.input.setInputType(EditorInfo.TYPE_CLASS_TEXT);
    this.input.addTextChangedListener(this);
    final InputMethodManager imm = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this.input, InputMethodManager.SHOW_IMPLICIT);
    builder.setView(this.input);
    builder.setPositiveButton("OK", this);
    builder.setNegativeButton("Abbrechen", this);
    return builder.create();
}

From source file:mobisocial.bento.todo.ui.TodoDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // extract UUID from intent
    mTodoUuid = getActivity().getIntent().getStringExtra(EXTRA_TODO_UUID);

    // View//from w w  w  .  j a v a  2s.  com
    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_todo_detail, container);

    mTitle = (EditText) mRootView.findViewById(R.id.todo_title);
    mDescription = (EditText) mRootView.findViewById(R.id.todo_description);
    mDescription.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE
                    || event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                Log.d(TAG, "onEditorAction");
                // clear focus
                v.clearFocus();

                // close keyboard
                InputMethodManager mgr = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.hideSoftInputFromWindow(mDescription.getWindowToken(), 0);

                return true;
            }
            return false;
        }
    });
    mImageView = (ImageView) mRootView.findViewById(R.id.todo_image);

    // retrieve Todo data
    if (mTodoUuid != null) {
        mTodoItem = mManager.getTodoListItem(mTodoUuid);
        if (mTodoItem != null) {
            mTitle.setText(mTodoItem.title);
            mDescription.setText(mTodoItem.description);
            if (mTodoItem.hasImage) {
                mImageView.setImageBitmap(mManager.getTodoBitmap(mTodoItem.uuid, IMG_WIDTH, IMG_HEIGHT, 0));
                mImageView.setVisibility(View.VISIBLE);
            } else {
                mImageView.setVisibility(View.GONE);
            }
        }
    }

    return mRootView;
}

From source file:com.example.reminder.alarm.LabelDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.label_dialog, container, false);

    mLabelBox = (EditText) view.findViewById(R.id.labelBox);
    mLabelBox.setText(label);//from  www  .j a  va2s .c o m
    mLabelBox.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                set(alarm);
                return true;
            }
            return false;
        }
    });

    final Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dismiss();
        }
    });

    final Button setButton = (Button) view.findViewById(R.id.setButton);
    setButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            set(alarm);
        }
    });

    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

    return view;
}

From source file:org.openlmis.core.view.widget.MMIAInfoList.java

public void initView(List<BaseInfoItem> list) {
    this.dataList = list;
    addHeaderView();//from   w ww .j a va 2 s . co m

    for (int i = 0; i < dataList.size(); i++) {
        BaseInfoItem item = dataList.get(i);
        if (item != null) {
            addItemView(item, i);
        }
    }

    editTexts.get(editTexts.size() - 2).setImeOptions(EditorInfo.IME_ACTION_DONE);
}