Example usage for android.view.inputmethod EditorInfo IME_ACTION_GO

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

Introduction

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

Prototype

int IME_ACTION_GO

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

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "go" operation to take the user to the target of the text they typed.

Usage

From source file:au.id.micolous.frogjump.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    lblStatus = (TextView) findViewById(R.id.lblStatus);
    txtGroupId = (EditText) findViewById(R.id.txtGroupId);

    sensitize(false);//from   w w w .  j a  v  a  2 s  .  c  om

    txtGroupId.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_GO) {
                onBtnJoinGroupClick(textView);
            }
            return false;
        }
    });

    setupUI();

    // Lets see if there was a Web Intent fired to start us up
    resolveIntent(getIntent());

    lblStatus.setText("Connecting to Frogjump API...");

    Util.updateCheck(this);
    lblStatus.setText(
            "Connecting to Cloud Messaging...  If this takes more than a few seconds, rotate your device to try again.");

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            boolean sentToken = sharedPreferences.getBoolean(ApplicationPreferences.SENT_TOKEN_TO_SERVER,
                    false);
            if (sentToken) {
                lblStatus.setText("Acquired token from Cloud Messaging.");
                // Leave any group we are a member of.
                Util.sendGcmMessage("part");

                sensitize(true);

                // Check if there is an auto-join for us
                if (auto_join) {
                    auto_join = false;
                    onBtnJoinGroupClick(txtGroupId);
                }
            } else {
                lblStatus.setText("Could not acquire token from Cloud Messaging. Check network connection.");
                sensitize(false);
            }
        }
    };

    if (isPlayServicesAvailable()) {
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }

}

From source file:org.gluu.oxpush2.app.MainActivityFragment.java

@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        submit();/*from   w w w  .ja v  a2s  .c  o  m*/
        return true;
    }

    return false;
}

From source file:net.olejon.mdapp.CalculatorsActivity.java

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

    // Input manager
    final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
            Context.INPUT_METHOD_SERVICE);

    // Layout//from  ww w  .java2s  .  co  m
    setContentView(R.layout.activity_calculators);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.calculators_toolbar);
    toolbar.setTitle(getString(R.string.calculators_title));

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // BMI
    final EditText bmiEditText = (EditText) findViewById(R.id.calculators_bmi_height);
    final TextView bmiButton = (TextView) findViewById(R.id.calculators_bmi_button);

    bmiButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            inputMethodManager.hideSoftInputFromWindow(bmiEditText.getWindowToken(), 0);

            calculateBmi();
        }
    });

    bmiEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_GO || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                inputMethodManager.hideSoftInputFromWindow(bmiEditText.getWindowToken(), 0);

                calculateBmi();

                return true;
            }

            return false;
        }
    });

    // Waist measurement
    final EditText waistMeasurementEditText = (EditText) findViewById(R.id.calculators_waist_measurement);
    final TextView waistMeasurementButton = (TextView) findViewById(R.id.calculators_waist_measurement_button);

    waistMeasurementButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            inputMethodManager.hideSoftInputFromWindow(waistMeasurementEditText.getWindowToken(), 0);

            calculateWaistMeasurement();
        }
    });

    waistMeasurementEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_GO || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                inputMethodManager.hideSoftInputFromWindow(waistMeasurementEditText.getWindowToken(), 0);

                calculateWaistMeasurement();

                return true;
            }

            return false;
        }
    });

    // Corrected QT time
    final EditText correctedQtTimeEditText = (EditText) findViewById(
            R.id.calculators_corrected_qt_time_rr_interval);
    final TextView correctedQtTimeButton = (TextView) findViewById(R.id.calculators_corrected_qt_time_button);

    correctedQtTimeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            inputMethodManager.hideSoftInputFromWindow(correctedQtTimeEditText.getWindowToken(), 0);

            calculateCorrectedQtTime();
        }
    });

    correctedQtTimeEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_GO || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                inputMethodManager.hideSoftInputFromWindow(correctedQtTimeEditText.getWindowToken(), 0);

                calculateCorrectedQtTime();

                return true;
            }

            return false;
        }
    });
}

From source file:com.hardcopy.retrowatch.RetroWebView.java

public void initialize(Context c, IWebViewListener l) {
    mContext = c;//from  ww  w .  j a  v  a  2  s  .c o m
    mWebViewListener = l;
    mIMM = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);

    //-----------------------------------------------------------------------------
    // Initialize layout
    //-----------------------------------------------------------------------------
    mEditURL.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                actionLoadURL(null);
                // InputMethodManager.HIDE_IMPLICIT_ONLY as the second parameter to ensure 
                // you only hide the keyboard when the user didn't explicitly force it to appear (by holding down menu)
                mIMM.hideSoftInputFromWindow(mEditURL.getWindowToken(), 0);
            }
            return true;
        }
    });

    mMsgWait = mContext.getString(R.string.warning_loading_wait);

    //-----------------------------------------------------------------------------
    // Create Web-View and set clients
    //-----------------------------------------------------------------------------
    mWebViewClient = new RetroWebViewClient();
    mChromeClient = new RetroChromeClient();
    mWebView.setWebViewClient(mWebViewClient);
    mWebView.setWebChromeClient(mChromeClient);

    // Set Web-View features
    mWebViewSettings = mWebView.getSettings();
    mWebViewSettings.setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new AndroidBridge(), "hotclip"); // param 2 : JavaScript use this parameter
    // ex) javascript call: function getResult() { window.hotclip.setResult('ERROR'); }

    mWebViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    mWebViewSettings.setBuiltInZoomControls(true);
    mWebViewSettings.setLoadWithOverviewMode(true);
    mWebViewSettings.setUseWideViewPort(true);
    //mWebViewSettings.setDatabaseEnabled(true);
    mWebViewSettings.setDomStorageEnabled(true);

    // Set cache size to 8 mb by default. should be more than enough
    //      mWebViewSettings.setAppCacheMaxSize(1024*1024*8);

    // Enable HTML5 Application Cache
    //      String appCachePath = mContext.getCacheDir().getAbsolutePath();
    //      mWebViewSettings.setAppCachePath(appCachePath);
    //      mWebViewSettings.setAllowFileAccess(true);
    //      mWebViewSettings.setAppCacheEnabled(true);
    //      mWebViewSettings.setCacheMode(WebSettings.LOAD_DEFAULT);

    //      GeoClient geo = new GeoClient();
    //      webview.setWebChromeClient(geo);
    //      mWebViewSettings.setGeolocationEnabled(true);
    //      mWebViewSettings.setGeolocationDatabasePath(<path>);

}

From source file:org.videolan.vlc.gui.MRLPanelFragment.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (keyCode == EditorInfo.IME_ACTION_DONE || keyCode == EditorInfo.IME_ACTION_GO
            || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
        return processUri();
    }/*  w ww  .  j a  va 2s .c  o m*/
    return false;
}

From source file:nl.thehyve.transmartclient.fragments.AddNewServerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_addnewserver, container, false);
    getActivity().setTitle(R.string.addnewserver);

    final EditText serverUrlField = (EditText) rootView.findViewById(R.id.serverUrlField);
    final EditText serverLabelField = (EditText) rootView.findViewById(R.id.serverLabelField);
    final Button connect_button = (Button) rootView.findViewById(R.id.connect_button);

    if (serverUrl != null || serverLabel != null) {
        serverUrlField.setText(serverUrl);
        serverLabelField.setText(serverLabel);
    }//from ww  w .  j a  va  2  s  . c o m

    if (waitingForToken) {
        // TODO show loading sign
        serverUrlField.setEnabled(false);
        serverLabelField.setEnabled(false);
        connect_button.setEnabled(false);
    }

    LinearLayout exampleContainer = (LinearLayout) rootView.findViewById(R.id.exampleContainer);
    exampleContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            serverUrlField.setText(getString(R.string.urlExample));
            serverLabelField.setText(getString(R.string.labelExample));
        }
    });

    serverLabelField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                connect_button.performClick();
                return true;
            }
            return false;
        }
    });

    return rootView;
}

From source file:org.chromium.content_shell.Shell.java

private void initializeUrlField() {
    mUrlTextView = (EditText) findViewById(R.id.url);
    mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
        @Override// w  w  w. j  a v a 2 s .  c  o m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId != EditorInfo.IME_ACTION_GO)
                    && (event == null || event.getKeyCode() != KeyEvent.KEYCODE_ENTER
                            || event.getAction() != KeyEvent.ACTION_DOWN)) {
                return false;
            }
            loadUrl(mUrlTextView.getText().toString());
            setKeyboardVisibilityForUrl(false);
            mContentView.requestFocus();
            return true;
        }
    });
    mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setKeyboardVisibilityForUrl(hasFocus);
            mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
            mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
            if (!hasFocus) {
                mUrlTextView.setText(mContentView.getUrl());
            }
        }
    });
}

From source file:net.vivekiyer.GAL.Configure.java

@SuppressLint("NewApi")
@Override//  w  w w .j a  v a  2 s.co  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.configure);

    // Hook up the on click handler for the button
    Button button = (Button) findViewById(R.id.buttonSignIn);
    button.setOnClickListener(this);

    // Get the preferences that were entered by the user and display those to the user 
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    String domain = mPreferences.getString(KEY_DOMAIN_PREFERENCE, ""), //$NON-NLS-1$
            user = mPreferences.getString(KEY_USERNAME_PREFERENCE, ""); //$NON-NLS-1$
    user = domain + (domain.length() > 0 ? "\\" : "") + user; //$NON-NLS-1$ //$NON-NLS-2$
    if (user.length() > 0)
        setTextForId(R.id.txtDomainUserName, user);
    setTextForId(R.id.txtPassword, mPreferences.getString(KEY_PASSWORD_PREFERENCE, "")); //$NON-NLS-1$
    setTextForId(R.id.txtServerName, mPreferences.getString(KEY_SERVER_PREFERENCE, "")); //$NON-NLS-1$
    setValueForCheckbox(R.id.chkUseSSL, mPreferences.getBoolean(KEY_USE_SSL, true));
    setValueForCheckbox(R.id.chkAcceptAllSSLCert, mPreferences.getBoolean(KEY_ACCEPT_ALL_CERTS, true));

    EditText text = (EditText) findViewById(R.id.txtServerName);
    text.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                connect();
                return true;
            }
            return false;
        }
    });

    if (!Utility.isPreHoneycomb()) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        //         actionBar.setBackgroundDrawable(new ColorDrawable(Color.LTGRAY));
    }
}

From source file:org.amahi.anywhere.activity.AuthenticationActivity.java

private void setUpAuthenticationTextListener() {
    getUsernameEdit().addTextChangedListener(this);
    getPasswordEdit().addTextChangedListener(this);
    getPasswordEdit().setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override/*from  w  w w .j a  va 2s  .  c o m*/
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                onClick(getAuthenticationButton());
                handled = true;
            }
            return handled;
        }
    });
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

protected void resetContent() {
    comicDef = makeComicDef();/* w w  w  .  j a va 2s  .c  om*/
    provider = comicDef.getProvider();
    comicInfo = provider.createEmptyComicInfo();

    //Only hide the title bar if we're running an android less than Android 3.0
    if (VersionHacks.getSdkInt() < 11)
        requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);
    webview = (HackedWebView) findViewById(R.id.viewer);
    title = (TextView) findViewById(R.id.title);
    comicIdSel = (EditText) findViewById(R.id.comicIdSel);

    webview.requestFocus();
    zoom = webview.getZoomControls();

    webview.setClickable(true);
    webview.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!"".equals(comicInfo.getAlt()))
                showDialog(DIALOG_SHOW_HOVER_TEXT);
        }
    });

    title.setText(comicInfo.getTitle());

    comicIdSel.setText(comicInfo.getId());
    if (comicDef.idsAreNumbers())
        comicIdSel.setInputType(InputType.TYPE_CLASS_NUMBER);
    comicIdSel.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String text = comicIdSel.getText().toString();
            if (!text.equals("") && (actionId == EditorInfo.IME_ACTION_GO
                    || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
                loadComic(createComicUri(text));
                comicIdSel.setText("");
                return true;
            }
            return false;
        }
    });
    comicIdSel.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (hasFocus) {
                comicIdSel.setText("");
                imm.showSoftInput(comicIdSel, InputMethodManager.SHOW_IMPLICIT);
            } else {
                imm.hideSoftInputFromWindow(comicIdSel.getWindowToken(), 0);
            }
        }
    });

    ((Button) findViewById(R.id.firstBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFirst();
        }
    });

    ((Button) findViewById(R.id.prevBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToPrev();
        }
    });

    ((Button) findViewById(R.id.nextBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToNext();
        }
    });

    ((Button) findViewById(R.id.finalBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFinal();
        }
    });

    ((ImageView) findViewById(R.id.randomBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToRandom();
        }
    });

    bookmarkBtn = (ImageView) findViewById(R.id.bookmarkBtn);
    bookmarkBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            toggleBookmark();
        }
    });
    refreshBookmarkBtn();
}