Example usage for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY

List of usage examples for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY.

Prototype

int HIDE_IMPLICIT_ONLY

To view the source code for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestHideSelf(int) to indicate that the soft input window should only be hidden if it was not explicitly shown by the user.

Usage

From source file:com.example.skode6.scanenvy.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*from w  ww . j  a  v  a2s  .c  o  m*/
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            //loadHistory(query);
            return false;
        }
    });
    if (searchView != null) {
        searchView.setIconifiedByDefault(true);
        searchView.setFocusable(true);
        searchView.setIconified(true);
        searchView.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(searchView, InputMethodManager.HIDE_IMPLICIT_ONLY);
                fabToolbar.hide();
            }
        });
        searchView.setFocusableInTouchMode(false);
        searchView.setOnClickListener(clickText());
        searchView.setOnFocusChangeListener(focusText());
    } else {
        Toast toast = Toast.makeText(getApplicationContext(), "Not Null", Toast.LENGTH_SHORT);
        toast.show();
    }
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
    return super.onCreateOptionsMenu(menu);
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);//from www .j a  va 2  s .  c om
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Utilities.Log("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Utilities.encryption("0000" + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*            check network*/

            /*            prepare params for server*/
            HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //               //file_name
            //               params.add(new BasicNameValuePair("userID","0000"));
            //               //function
            //               params.add(new BasicNameValuePair("pre","1"));
            //               //data
            //               params.add(new BasicNameValuePair("password",pinStr));

            /*            check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(final Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*  w  w w.j av a  2  s .c o  m*/
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Util.Log_debug("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Util.encryption(context, Util.ADMIN_UID + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*              check network*/

            /*              prepare params for server*/
            HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //              //file_name
            //              params.add(new BasicNameValuePair("userID","0000"));
            //              //function
            //              params.add(new BasicNameValuePair("pre","1"));
            //              //data
            //              params.add(new BasicNameValuePair("password",pinStr));

            /*              check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:net.olejon.spotcommander.AddComputerActivity.java

private void addComputer() {
    final EditText computerNameInput = (EditText) findViewById(R.id.add_computer_name);
    final EditText computerUriInput = (EditText) findViewById(R.id.add_computer_uri);
    final EditText computerUsernameInput = (EditText) findViewById(R.id.add_computer_username);
    final EditText computerPasswordInput = (EditText) findViewById(R.id.add_computer_password);

    computerNameInput.addTextChangedListener(new TextWatcher() {
        @Override/*from   www. java  2s . com*/
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            mAddComputerNameInputLayout.setError(null);
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    computerUriInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            mAddComputerUriInputLayout.setError(null);
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    final String computerName = computerNameInput.getText().toString().trim();
    final String computerUri = computerUriInput.getText().toString().trim();
    final String computerUsername = computerUsernameInput.getText().toString().trim();
    final String computerPassword = computerPasswordInput.getText().toString().trim();

    final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
            Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(computerNameInput.getWindowToken(),
            InputMethodManager.HIDE_IMPLICIT_ONLY);

    if (mNetworkScanTask != null && mNetworkScanTask.getStatus() == AsyncTask.Status.RUNNING) {
        mTools.showToast(getString(R.string.add_computer_scanning_network), 0);
    } else if (computerName.equals("")) {
        mAddComputerNameInputLayout.setError(getString(R.string.add_computer_invalid_name));
    } else if (!computerUri.matches("^https?://.*")) {
        mAddComputerUriInputLayout.setError(getString(R.string.add_computer_invalid_uri));
    } else {
        final ContentValues contentValues = new ContentValues();

        contentValues.put(MainSQLiteHelper.COLUMN_NAME, computerName);
        contentValues.put(MainSQLiteHelper.COLUMN_URI, computerUri);
        contentValues.put(MainSQLiteHelper.COLUMN_USERNAME, computerUsername);
        contentValues.put(MainSQLiteHelper.COLUMN_PASSWORD, computerPassword);
        contentValues.put(MainSQLiteHelper.COLUMN_NETWORK_NAME, "");
        contentValues.put(MainSQLiteHelper.COLUMN_NETWORK_DEFAULT, 0);

        final SQLiteDatabase database = new MainSQLiteHelper(mContext).getWritableDatabase();

        database.insert(MainSQLiteHelper.TABLE_COMPUTERS, null, contentValues);

        database.close();

        finish();
    }
}

From source file:com.brookmanholmes.bma.ui.newmatchwizard.CreateNewMatchActivity.java

public void showKeyboard() {
    if (pager.getCurrentItem() == 0) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }//from   ww w.ja  va 2 s . c o m
}

From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java

protected boolean newTask(final String name) {
    this.newTask.setText(null);
    final InputMethodManager imm = (InputMethodManager) this.main
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(this.newTask.getWindowToken(), 0);
    this.newTask.clearFocus();
    if (name.equals("")) {
        this.newTask.setOnFocusChangeListener(null);
        imm.showSoftInput(this.newTask, InputMethodManager.HIDE_IMPLICIT_ONLY);
        return true;
    }//from  w  ww.j a  v  a 2s .com
    final ListMirakel list = this.main.getCurrentList();
    final Task createdTask = Semantic.createTask(name, Optional.fromNullable(list), true, getActivity());
    getLoaderManager().restartLoader(0, null, this);
    this.main.setCurrentTask(createdTask, false);
    this.main.getListFragment().update();
    if (!MirakelCommonPreferences.hideKeyboard()) {
        focusNew(true);
    }
    this.main.updateShare();
    return true;
}

From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealSearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_search_add_item_fatsecret, container, false);
    // Change the notification bar color
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window w = getActivity().getWindow();
        w.setStatusBarColor(getResources().getColor(R.color.light_grey));
    }/* ww  w.j a  va 2  s  . co  m*/
    // Get MealType (snack, breakfast, lunch, dinner)
    Bundle extras = getActivity().getIntent().getExtras();
    if (extras != null) {
        mealType = extras.getString(Globals.MEAL_TYPE);
    }
    // Initialize FatSecretSearchMethod
    mFatSecretSearch = new FatSecretSearchMethod();

    mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swiperefresh);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.primary, R.color.red, R.color.primary_dark);
    mSwipeRefreshLayout.setProgressViewOffset(true, Equations.dpToPx(getActivity(), 0),
            Equations.dpToPx(getActivity(), 112));
    mSwipeRefreshLayout.setEnabled(false);

    mEtSearch = (EditText) v.findViewById(R.id.etSearch);
    // LogQuickSearch adapter to add items that have not been saved already
    mRecentLogAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all());
    // List for adding items to the
    mItem = new ArrayList<>();
    // Set to prevent duplicates being saved in LogQuickSearch
    set = new HashSet<>();
    /**
     * set mListViewSearchResults adapter to SearchAdapterItemResult
     */
    llSearch = (LinearLayout) v.findViewById(R.id.llSearch);
    listSearch = (ListView) v.findViewById(R.id.listSearch);
    searchLine = v.findViewById(R.id.searchLine);
    logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all());
    mEtSearchAdapter = new SearchAdapterItemResult(getActivity(), mItem);

    mListViewSearchResults = (ListView) v.findViewById(R.id.listView);
    ViewGroup header = (ViewGroup) inflater.inflate(R.layout.list_search_header, mListViewSearchResults, false);
    mListViewSearchResults.addHeaderView(header, null, false);
    mListViewSearchResults.setAdapter(mEtSearchAdapter);
    mListViewSearchResults.setOnScrollListener(this);
    mListViewSearchResults.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(getActivity(), SaveSearchAddItemActivityMain.class);
            i.putExtra(Globals.MEAL_TYPE, mealType);
            i.putExtra(Globals.MEAL_ID, mItem.get(position - 1).getID());
            i.putExtra(Globals.MEAL_BRAND, mItem.get(position - 1).getBrand());
            i.putExtra(Globals.MEAL_FAVORITE, "false");
            startActivity(i);
        }
    });
    // Toolbar
    mToolbarSearch = (Toolbar) v.findViewById(R.id.toolbar_search);
    mToolbarSearch.inflateMenu(R.menu.menu_search);
    mToolbarSearch.setNavigationIcon(R.mipmap.ic_arrow_back_grey);
    mToolbarSearch.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().getSupportFragmentManager().popBackStack();
        }
    });
    mToolbarSearch.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.action_clear) {
                mEtSearch.setText("");
            }
            if (menuItem.getItemId() == R.id.action_voice) {
                promptSpeechInput();
            }
            return false;
        }
    });
    mEtSearch.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mEtSearch.getText().toString().length() >= 1) {
                mToolbarSearch.getMenu().clear();
                mToolbarSearch.inflateMenu(R.menu.menu_search_clear);
                logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0,
                        LogQuickSearch.FilterByName(mEtSearch.getText().toString()));
                listSearch.setAdapter(logQuickSearchAdapter);
            } else {
                mToolbarSearch.getMenu().clear();
                mToolbarSearch.inflateMenu(R.menu.menu_search);
                logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all());
                listSearch.setAdapter(logQuickSearchAdapter);
            }
            mItem.clear();
            updateListView();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    // Quick Search Clicked, start search based on list Item clicked from last fragment
    Bundle extrasFromRecentCliced = this.getArguments();
    if (extrasFromRecentCliced != null) {
        String mealName = extrasFromRecentCliced.getString("MealName");
        if (mealName != null) {
            mEtSearch.setText(mealName);
            mToolbarSearch.getMenu().clear();
            mToolbarSearch.inflateMenu(R.menu.menu_search_clear);
            searchFood(mealName, 0);
        }
    } else {
        mEtSearch.requestFocus();
        ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }
    /**
     * Handles softKeyboard search icon being clicked
     */
    mEtSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mEtSearch.getWindowToken(), 0);
                listSearch.setVisibility(View.GONE);
                searchLine.setVisibility(View.GONE);
                searchFood(mEtSearch.getText().toString(), 0);
                mItem.clear();
                mEtSearchAdapter.notifyDataSetChanged();
                mEtSearch.clearFocus();
                return true;
            }
            return false;
        }
    });

    listSearch.setAdapter(logQuickSearchAdapter);
    listSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            LogQuickSearch logQuickSearch = logQuickSearchAdapter.getItem(position);
            mEtSearch.setText(logQuickSearch.getName());
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mEtSearch.getWindowToken(), 0);
            listSearch.setVisibility(View.GONE);
            searchLine.setVisibility(View.GONE);
            searchFood(logQuickSearch.getName(), 0);
            mItem.clear();
            mEtSearchAdapter.notifyDataSetChanged();
            mEtSearch.clearFocus();
        }
    });
    updateListView();
    return v;
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private void setListeners() {
    // TODO Auto-generated method stub
    Log.d(TAG, "Ontabchangedlistener!!~~~");
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override/*from w w  w.  j  av  a 2s.  c  o  m*/
        public void onTabChanged(String arg0) {
            // TODO Auto-generated method stub
            Log.d(TAG, "~~" + arg0);

            setHints();

            if (arg0.equals("Assign ID")) {
                imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);

                Log.d(TAG, "assign id ");

            } else {

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Log.d(TAG, "deassign id");

            }
        }

    });

    AssignButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "assign btn " + asID.getText().toString());

            //editor.putString(ASID, asID.getText().toString());
            //format check

            //editor.putString(ASPWD, "");
            //editor.commit();
            //setHints();

            /*              check network*/

            /*              prepare params for server*/
            String asedID = asID.getText().toString();
            Log.d(TAG, "get from edittext is " + asedID);

            String data = null;
            try {
                data = Util.encryption(AdminManageActivity.this, asedID + "," + "2");
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //              //file_name
            //              params.add(new BasicNameValuePair("userID",asedID));
            //              //function
            //              params.add(new BasicNameValuePair("pre","2"));
            //              //data
            //              //params.add(new BasicNameValuePair("password",""));

            /*              check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result2 ", result);

                    if (result.equals("UserIDIsNotSet")) {
                        //add in web page first

                        String s1 = getString(R.string.assign_id_null);
                        assignFailDialog(ctx, s1).show();

                    } else if (result.equals("UserIDIsUsed")) {
                        String s2 = getString(R.string.assing_id_exist) + asedID;
                        assignConfirmDialog(ctx, s2, true).show();

                    } else if (result.equals("UserIDIsNotActive")) {
                        //assign
                        String s3 = getString(R.string.assign_id_new) + asedID;
                        assignConfirmDialog(ctx, s3, false).show();

                    } else {
                        String s4 = getString(R.string.assign_id_wrong);
                        assignFailDialog(ctx, s4).show();

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String s4 = getString(R.string.assign_id_net_error);
                assignFailDialog(ctx, s4).show();
            }
        }
    });

    RemoveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "remove btn ");

            //add a confirm dialog

            setHints();
            Log.d(TAG, "cur is " + currentAssID);

            if (!currentAssID.equals("")) {
                removeDialog(ctx).show();
            }
        }
    });
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private void setListeners() {
    // TODO Auto-generated method stub
    Log.d(TAG, "Ontabchangedlistener!!~~~");
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override//w w w . j  av a  2s  .c  o  m
        public void onTabChanged(String arg0) {
            // TODO Auto-generated method stub
            Log.d(TAG, "~~" + arg0);

            setHints();

            if (arg0.equals("Assign ID")) {
                imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);

                Log.d(TAG, "assign id ");

            } else {

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Log.d(TAG, "deassign id");

            }
        }

    });

    AssignButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "assign btn " + asID.getText().toString());

            //editor.putString(ASID, asID.getText().toString());
            //format check

            //editor.putString(ASPWD, "");
            //editor.commit();
            //setHints();

            /*            check network*/

            /*            prepare params for server*/
            String asedID = asID.getText().toString();
            Log.d(TAG, "get from edittext is " + asedID);

            String data = null;
            try {
                data = Utilities.encryption(asedID + "," + "2");
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //               //file_name
            //               params.add(new BasicNameValuePair("userID",asedID));
            //               //function
            //               params.add(new BasicNameValuePair("pre","2"));
            //               //data
            //               //params.add(new BasicNameValuePair("password",""));

            /*            check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result2 ", result);

                    if (result.equals("UserIDIsNotSet")) {
                        //add in web page first

                        String s1 = getString(R.string.assign_id_null);
                        assignFailDialog(ctx, s1).show();

                    } else if (result.equals("UserIDIsUsed")) {
                        String s2 = getString(R.string.assing_id_exist) + asedID;
                        assignConfirmDialog(ctx, s2, true).show();

                    } else if (result.equals("UserIDIsNotActive")) {
                        //assign
                        String s3 = getString(R.string.assign_id_new) + asedID;
                        assignConfirmDialog(ctx, s3, false).show();

                    } else {
                        String s4 = getString(R.string.assign_id_wrong);
                        assignFailDialog(ctx, s4).show();

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String s4 = getString(R.string.assign_id_net_error);
                assignFailDialog(ctx, s4).show();
            }
        }
    });

    RemoveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "remove btn ");

            //add a confirm dialog

            setHints();
            Log.d(TAG, "cur is " + currentAssID);

            if (!currentAssID.equals("")) {
                removeDialog(ctx).show();
            }
        }
    });
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java

private void InitiateSearch() {
    card_search.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override/*from  w  w w .j  ava 2  s .  c om*/
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            v.removeOnLayoutChangeListener(this);
            InitiateSearch.handleToolBar(getActivity(), card_search, view_search, listView, edit_text_search,
                    line_divider);
        }
    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            LogQuickSearch logQuickSearch = logQuickSearchAdapter.getItem(position);
            edit_text_search.setText(logQuickSearch.getName());
            listView.setVisibility(View.GONE);
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(edit_text_search.getWindowToken(), 0);
            searchFood(logQuickSearch.getName(), 0);
        }
    });
    edit_text_search.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (edit_text_search.getText().toString().length() == 0) {
                logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all());
                listView.setAdapter(logQuickSearchAdapter);
                clearSearch.setImageResource(R.mipmap.ic_keyboard_voice);
                IsAdapterEmpty();
            } else {
                logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0,
                        LogQuickSearch.FilterByName(edit_text_search.getText().toString()));
                listView.setAdapter(logQuickSearchAdapter);
                clearSearch.setImageResource(R.mipmap.ic_close);
                IsAdapterEmpty();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    clearSearch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (edit_text_search.getText().toString().length() != 0) {
                edit_text_search.setText("");
                searchBack.setVisibility(View.GONE);
                listView.setVisibility(View.VISIBLE);
                clearItems();
                ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
                IsAdapterEmpty();
            } else {
                promptSpeechInput(edit_text_search);
            }
        }
    });
}