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.mifos.mifosxdroid.formwidgets.FormEditText.java

public FormEditText(Context context, String name) {

    super(context, name);
    label = new TextView(context);
    label.setText(getDisplayText());/*from   www.j  a  va 2  s. com*/
    label.setLayoutParams(FormWidget.defaultLayoutParams);

    input = new EditText(context);
    input.setLayoutParams(FormWidget.defaultLayoutParams);
    input.setImeOptions(EditorInfo.IME_ACTION_DONE);
    isDateAvailable = false;
    layout.addView(label);
    layout.addView(input);

}

From source file:net.zorgblub.typhon.fragment.AddBookmarkFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();

    View view = inflater.inflate(R.layout.fragment_add_bookmark, null);

    this.inputField = (EditText) view.findViewById(R.id.bookmark_name);
    this.inputField.setText(this.initialText);

    inputField.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            handleAction();/*w w  w  .  j  a va 2  s .  c  om*/
            return true;
        } else {
            return false;
        }
    });

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.add_bookmark).setView(view)
            .setPositiveButton(R.string.add, (dialog, which) -> handleAction())
            .setNegativeButton(android.R.string.cancel, null).create();
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle args = getArguments();/* w w  w .j a  v  a  2 s .  com*/
    mEditText = new EditText(getActivity());
    getDialog().setTitle(args.getString("dialogTitle"));
    // Show soft keyboard automatically
    mEditText.setInputType(InputType.TYPE_CLASS_TEXT);
    mEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mEditText.requestFocus();
    getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    mEditText.setOnEditorActionListener(this);
    mEditText.setId(1);
    mEditText.setText(args.getString("value"));
    //input.setSingleLine();
    return mEditText;
}

From source file:ru.evilduck.framework.ui.DemoActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);//ww w .j  av a 2  s .c o  m

    text1 = (EditText) findViewById(R.id.editText1);
    text2 = (EditText) findViewById(R.id.editText2);
    text2.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent event) {
            if (id == EditorInfo.IME_ACTION_DONE) {
                doIt();
            }
            return false;
        }
    });

    findViewById(R.id.button_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doIt();
        }

    });
}

From source file:es.curso.android.fragments.EditNameDialog.java

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

From source file:org.hedgewars.hedgeroid.StartNetgameDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    SharedPreferences prefs = getActivity().getSharedPreferences("settings", Context.MODE_PRIVATE);
    final String playerName = prefs.getString(PREF_PLAYERNAME, "Player");
    final EditText editText = new EditText(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    editText.setText(playerName);//from  ww  w  .  j  av a  2s .c o m
    editText.setHint(R.string.start_netgame_dialog_playername_hint);
    editText.setId(android.R.id.text1);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setSingleLine();

    builder.setTitle(R.string.start_netgame_dialog_title);
    builder.setMessage(R.string.start_netgame_dialog_message);
    builder.setView(editText);
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            editText.setText(playerName);
        }
    });

    editText.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                startConnection(v.getText().toString());
                handled = true;
            }
            return handled;
        }
    });

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            startConnection(editText.getText().toString());
        }
    });

    return builder.create();
}

From source file:com.mario22gmail.license.nfc_project.FragmentBrowser.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View v = inflater.inflate(R.layout.fragment_browser, container, false);
    mWebview = (WebView) v.findViewById(R.id.webViewFb);

    Intent myIntent = new Intent("fragment.setTitle");
    myIntent.putExtra("Title", "Browser");
    NavigationDrawerActivity.getAppContext().sendBroadcast(myIntent);
    urlEditText = (EditText) v.findViewById(R.id.searchForGoogle);
    EditTextFocusChangeListner textLisner = new EditTextFocusChangeListner(getContext(), R.id.searchForGoogle);
    urlEditText.setOnFocusChangeListener(textLisner);
    urlEditText.setSingleLine();//w w  w  .j a v  a2 s .com
    urlEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager imm = (InputMethodManager) getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                String query = urlEditText.getText().toString();
                if (!query.isEmpty()) {

                    String url = "https://www.google.com/search?q=" + query;
                    mWebview.loadUrl(url);
                    mWebview.setWebViewClient(new WebViewClient() {
                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                            view.loadUrl(url);
                            return true;
                        }
                    });
                }
            }
            return true;
        }
    });

    final Button searchButton = (Button) v.findViewById(R.id.searchOnGoogleButton);
    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager imm = (InputMethodManager) getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            String query = urlEditText.getText().toString();
            if (!query.isEmpty()) {
                String url = "https://www.google.com/search?q=" + query;
                mWebview.loadUrl(url);
                mWebview.setWebViewClient(new WebViewClient() {
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        view.loadUrl(url);
                        return true;
                    }
                });
            }
        }
    });

    if (!js.equals("") && !url.equals("")) {
        OpenWebSite(url, js);
        Log.i("nfc_debug", "A trecut");
    }

    return v;
    //        inflater.inflate(R.layout.fragment_browser, container, false);

}

From source file:cc.softwarefactory.lokki.android.activities.SignUpActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    aq = new AQuery(this);

    try {/*w ww .j a va  2s .  c o m*/
        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, false, null, null, null, null);
        startActivityForResult(intent, REQUEST_CODE_EMAIL);

    } catch (ActivityNotFoundException anf) {
        // No problem. Simply don't do anything
    }

    aq.id(R.id.email).getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                doSignUp();
                return true;
            }

            return false;
        }
    });
}

From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java

public filter_dialog(Context cx, List<NameValuePair> data) {
    super(cx);//from   ww w.  j av a  2s  .  c o m
    this.cx = cx;
    this.webData = data;
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    vocl = new View.OnClickListener() {
        public void onClick(View v) {
            onCheckboxClick(v);
        }
    };

    maxLines = new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView tv, int action, KeyEvent key) {
            boolean handled = false;
            if (action == EditorInfo.IME_ACTION_DONE) {
                setMaxLines(tv.getText().toString());
                tv.setText(getNamedData("iPage"));
                InputMethodManager imm = (InputMethodManager) tv.getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(tv.getWindowToken(), 0);
                handled = true;
            }
            return handled;
        }
    };
    rateListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            rateSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    licenseListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            licenseSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    placementListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            placementSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };

}

From source file:com.emartynov.android.app.urlsetter.android.ui.fragment.EnterShortenedUrlFragment.java

@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId) {
        onClick(null);/*  w  w w  . j  a va2 s . c o  m*/
        return true;
    }
    return false;
}