Example usage for android.view.inputmethod InputMethodManager SHOW_FORCED

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

Introduction

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

Prototype

int SHOW_FORCED

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

Click Source Link

Document

Flag for #showSoftInput to indicate that the user has forced the input method open (such as by long-pressing menu) so it should not be closed until they explicitly do so.

Usage

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

private void handleSearchFavorite() {
    if (card_search_fav.getVisibility() == View.VISIBLE) {
        searchFavorite.setVisibility(View.VISIBLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final Animator animatorHide = ViewAnimationUtils.createCircularReveal(card_search_fav,
                    card_search_fav.getWidth() - (int) convertDpToPixel(24, getActivity()),
                    (int) convertDpToPixel(23, getActivity()),
                    (float) Math.hypot(card_search_fav.getWidth(), card_search_fav.getHeight()), 0);
            animatorHide.addListener(new Animator.AnimatorListener() {
                @Override//from  w  ww .jav  a2 s  .co m
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    card_search_fav.setVisibility(View.GONE);
                    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(searchFavorite.getWindowToken(), 0);
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });

            animatorHide.setDuration(200);
            animatorHide.start();
        } else {
            favSearch.requestFocus();
            card_search_fav.setVisibility(View.GONE);
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(searchFavorite.getWindowToken(), 0);
        }
    } else {
        searchFavorite.setVisibility(View.INVISIBLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final Animator animator = ViewAnimationUtils.createCircularReveal(card_search_fav,
                    card_search_fav.getWidth() - (int) convertDpToPixel(24, getActivity()),
                    (int) convertDpToPixel(23, getActivity()), 0,
                    (float) Math.hypot(card_search_fav.getWidth(), card_search_fav.getHeight()));
            animator.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    favSearch.requestFocus();
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    favSearch.requestFocus();
                    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                            .toggleSoftInput(InputMethodManager.SHOW_FORCED,
                                    InputMethodManager.HIDE_IMPLICIT_ONLY);
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            card_search_fav.setVisibility(View.VISIBLE);
            if (card_search_fav.getVisibility() == View.VISIBLE) {
                animator.setDuration(300);
                animator.start();
            }
        } else {
            favSearch.requestFocus();
            card_search_fav.setVisibility(View.VISIBLE);
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
        }
    }
}

From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java

public void showSoftKeyBoard(View triggeringView) {
    InputMethodManager imm = (InputMethodManager) triggeringView.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

From source file:es.farfuteam.vncpp.controller.CanvasActivity.java

/**
 * @brief Makes a toggle of the keyboard
 * @details Makes a toggle of the keyboard
 *///from  w  w  w  . j av  a 2s.c  om
public void showKeyboard() {

    inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

    menu.toggle();
}

From source file:org.akvo.caddisfly.ui.activity.MainActivity.java

public void onSaveCalibration() {
    final Context context = this;
    final MainApp mainApp = (MainApp) this.getApplicationContext();

    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    final EditText input = new EditText(context);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(22) });

    alertDialogBuilder.setView(input);//from  w  w  w .j ava  2 s  . co m
    alertDialogBuilder.setCancelable(false);

    alertDialogBuilder.setTitle(R.string.saveCalibration);
    alertDialogBuilder.setMessage(R.string.giveNameForCalibration);

    alertDialogBuilder.setPositiveButton(R.string.ok, null);
    alertDialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            closeKeyboard(input);
            dialog.cancel();
        }
    });
    final AlertDialog alertDialog = alertDialogBuilder.create(); //create the box

    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

            Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {

                    if (!input.getText().toString().trim().isEmpty()) {
                        final ArrayList<String> exportList = new ArrayList<String>();

                        for (ColorInfo aColorList : mainApp.colorList) {
                            exportList.add(ColorUtils.getColorRgbString(aColorList.getColor()));
                        }

                        File external = Environment.getExternalStorageDirectory();
                        final String path = external.getPath() + Config.CALIBRATE_FOLDER_NAME;

                        File file = new File(path + input.getText());
                        if (file.exists()) {
                            AlertUtils.askQuestion(context, R.string.overwriteFile, R.string.nameAlreadyExists,
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            FileUtils.saveToFile(path, input.getText().toString(),
                                                    exportList.toString());
                                        }
                                    });
                        } else {
                            FileUtils.saveToFile(path, input.getText().toString(), exportList.toString());
                        }

                        closeKeyboard(input);
                        alertDialog.dismiss();
                    } else {
                        input.setError(getString(R.string.invalidName));
                    }
                }
            });
        }
    });

    input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {

            }
            return false;
        }
    });

    alertDialog.show();
    input.requestFocus();
    InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

}

From source file:br.liveo.searchliveo.SearchLiveo.java

/**
 * Show SearchLiveo//from ww w .jav a2 s .com
 */
public SearchLiveo show() {
    setActive(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        try {
            showAnimation();
        } catch (ClassCastException e) {
            throw new ClassCastException(mContext.getString(R.string.warning_with));
        }

    } else {

        Animation mFadeIn = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_in);
        mViewSearch.setEnabled(true);
        mViewSearch.setVisibility(View.VISIBLE);
        mViewSearch.setAnimation(mFadeIn);

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            }
        });
    }

    mEdtSearch.requestFocus();
    return this;
}

From source file:br.liveo.searchliveo.SearchCardLiveo.java

/**
 * Show SearchCardLiveo/*from  w w w  .  j a  v  a 2 s .com*/
 */
public SearchCardLiveo show() {
    setActive(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        try {
            showAnimation();
        } catch (ClassCastException e) {
            throw new ClassCastException(mContext.getString(R.string.warning_with));
        }

    } else {

        Animation mFadeIn = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_in);
        mCardSearch.setEnabled(true);
        mCardSearch.setVisibility(View.VISIBLE);
        mCardSearch.setAnimation(mFadeIn);

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            }
        });
    }

    mEdtSearch.requestFocus();
    return this;
}

From source file:org.connectbot.ConsoleActivity.java

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        StrictModeSetup.run();//  w ww  .  ja  v  a2 s .  c o  m
    }

    hardKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;

    clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    titleBarHide = prefs.getBoolean(PreferenceConstants.TITLEBARHIDE, false);
    if (titleBarHide && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // This is a separate method because Gradle does not uniformly respect the conditional
        // Build check. See: https://code.google.com/p/android/issues/detail?id=137195
        requestActionBar();
    }

    this.setContentView(R.layout.act_console);

    // hide status bar if requested by user
    if (prefs.getBoolean(PreferenceConstants.FULLSCREEN, false)) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    // TODO find proper way to disable volume key beep if it exists.
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // handle requested console from incoming intent
    if (icicle == null) {
        requested = getIntent().getData();
    } else {
        String uri = icicle.getString(STATE_SELECTED_URI);
        if (uri != null) {
            requested = Uri.parse(uri);
        }
    }

    inflater = LayoutInflater.from(this);

    toolbar = (Toolbar) findViewById(R.id.toolbar);

    pager = (TerminalViewPager) findViewById(R.id.console_flip);
    pager.addOnPageChangeListener(new TerminalViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            setTitle(adapter.getPageTitle(position));
            onTerminalChanged();
        }
    });
    adapter = new TerminalPagerAdapter();
    pager.setAdapter(adapter);

    empty = (TextView) findViewById(android.R.id.empty);

    stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group);
    stringPromptInstructions = (TextView) findViewById(R.id.console_password_instructions);
    stringPrompt = (EditText) findViewById(R.id.console_password);
    stringPrompt.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_UP)
                return false;
            if (keyCode != KeyEvent.KEYCODE_ENTER)
                return false;

            // pass collected password down to current terminal
            String value = stringPrompt.getText().toString();

            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return false;
            helper.setResponse(value);

            // finally clear password for next user
            stringPrompt.setText("");
            updatePromptVisible();

            return true;
        }
    });

    booleanPromptGroup = (RelativeLayout) findViewById(R.id.console_boolean_group);
    booleanPrompt = (TextView) findViewById(R.id.console_prompt);

    booleanYes = (Button) findViewById(R.id.console_prompt_yes);
    booleanYes.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return;
            helper.setResponse(Boolean.TRUE);
            updatePromptVisible();
        }
    });

    Button booleanNo = (Button) findViewById(R.id.console_prompt_no);
    booleanNo.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return;
            helper.setResponse(Boolean.FALSE);
            updatePromptVisible();
        }
    });

    fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed);

    // Preload animation for keyboard button
    keyboard_fade_in = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_in);
    keyboard_fade_out = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_out);

    keyboardGroup = (LinearLayout) findViewById(R.id.keyboard_group);

    keyboardAlwaysVisible = prefs.getBoolean(PreferenceConstants.KEY_ALWAYS_VISIVLE, false);
    if (keyboardAlwaysVisible) {
        // equivalent to android:layout_above=keyboard_group
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams.addRule(RelativeLayout.ABOVE, R.id.keyboard_group);
        pager.setLayoutParams(layoutParams);

        // Show virtual keyboard
        keyboardGroup.setVisibility(View.VISIBLE);
    }

    mKeyboardButton = (ImageView) findViewById(R.id.button_keyboard);
    mKeyboardButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View terminal = adapter.getCurrentTerminalView();
            if (terminal == null)
                return;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.toggleSoftInputFromWindow(terminal.getApplicationWindowToken(),
                    InputMethodManager.SHOW_FORCED, 0);
            terminal.requestFocus();
            hideEmulatedKeys();
        }
    });

    findViewById(R.id.button_ctrl).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_esc).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_tab).setOnClickListener(emulatedKeysListener);

    addKeyRepeater(findViewById(R.id.button_up));
    addKeyRepeater(findViewById(R.id.button_up));
    addKeyRepeater(findViewById(R.id.button_down));
    addKeyRepeater(findViewById(R.id.button_left));
    addKeyRepeater(findViewById(R.id.button_right));

    findViewById(R.id.button_home).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_end).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_pgup).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_pgdn).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f1).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f2).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f3).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f4).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f5).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f6).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f7).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f8).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f9).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f10).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f11).setOnClickListener(emulatedKeysListener);
    findViewById(R.id.button_f12).setOnClickListener(emulatedKeysListener);

    actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        if (titleBarHide) {
            actionBar.hide();
        }
        actionBar.addOnMenuVisibilityListener(new ActionBar.OnMenuVisibilityListener() {
            public void onMenuVisibilityChanged(boolean isVisible) {
                inActionBarMenu = isVisible;
                if (!isVisible) {
                    hideEmulatedKeys();
                }
            }
        });
    }

    final HorizontalScrollView keyboardScroll = (HorizontalScrollView) findViewById(R.id.keyboard_hscroll);
    if (!hardKeyboard) {
        // Show virtual keyboard and scroll back and forth
        showEmulatedKeys(false);
        keyboardScroll.postDelayed(new Runnable() {
            @Override
            public void run() {
                final int xscroll = findViewById(R.id.button_f12).getRight();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "smoothScrollBy(toEnd[" + xscroll + "])");
                }
                keyboardScroll.smoothScrollBy(xscroll, 0);
                keyboardScroll.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (BuildConfig.DEBUG) {
                            Log.d(TAG, "smoothScrollBy(toStart[" + (-xscroll) + "])");
                        }
                        keyboardScroll.smoothScrollBy(-xscroll, 0);
                    }
                }, 500);
            }
        }, 500);
    }

    // Reset keyboard auto-hide timer when scrolling
    keyboardScroll.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_MOVE:
                autoHideEmulatedKeys();
                break;
            case MotionEvent.ACTION_UP:
                v.performClick();
                return (true);
            }
            return (false);
        }
    });

    tabs = (TabLayout) findViewById(R.id.tabs);
    if (tabs != null)
        setupTabLayoutWithViewPager();

    pager.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showEmulatedKeys(true);
        }
    });

    // Change keyboard button image according to soft keyboard visibility
    // How to detect keyboard visibility: http://stackoverflow.com/q/4745988
    contentView = findViewById(android.R.id.content);
    contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Rect r = new Rect();
            contentView.getWindowVisibleDisplayFrame(r);
            int screenHeight = contentView.getRootView().getHeight();
            int keypadHeight = screenHeight - r.bottom;

            if (keypadHeight > screenHeight * 0.15) {
                // keyboard is opened
                mKeyboardButton.setImageResource(R.drawable.ic_keyboard_hide);
                mKeyboardButton.setContentDescription(
                        getResources().getText(R.string.image_description_hide_keyboard));
            } else {
                // keyboard is closed
                mKeyboardButton.setImageResource(R.drawable.ic_keyboard);
                mKeyboardButton.setContentDescription(
                        getResources().getText(R.string.image_description_show_keyboard));
            }
        }
    });
}

From source file:org.catnut.ui.ComposeTweetActivity.java

@Override
public boolean onMenuItemActionExpand(MenuItem item) {
    if (mAutoCompleteTextView == null) {
        mAutoCompleteTextView = (AutoCompleteTextView) item.getActionView().findViewById(R.id.mention_search);
        mAutoCompleteTextView.setThreshold(1); // ??
        mMentionSearchAdapter = new MentionSearchAdapter(ComposeTweetActivity.this);
        mAutoCompleteTextView.setAdapter(mMentionSearchAdapter);
    }//from   w w w. j av  a2  s  .  c  o  m
    //      Toast.makeText(ComposeTweetActivity.this, getString(R.string.mention_helper_toast), Toast.LENGTH_SHORT).show();
    final View clear = item.getActionView().findViewById(R.id.clear);
    clear.setOnClickListener(ComposeTweetActivity.this);
    mAutoCompleteTextView.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // no-op
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // no-op
        }

        @Override
        public void afterTextChanged(Editable s) {
            String text = s.toString();
            if (text.length() > 0) {
                clear.setVisibility(View.VISIBLE);
            } else {
                clear.setVisibility(View.GONE);
            }
            String key = text.trim();
            if (!TextUtils.isEmpty(key) && !key.equals(mCurKeywords)) {
                mCurKeywords = key;
                getLoaderManager().restartLoader(0, null, ComposeTweetActivity.this);
            }
        }
    });
    mAutoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) mMentionSearchAdapter.getItem(position);
            mText.getText().append(getString(R.string.mention_text,
                    cursor.getString(cursor.getColumnIndex(User.screen_name))));
            mText.setSelection(mText.length());
        }
    });
    mText.clearFocus();
    mAutoCompleteTextView.requestFocus();
    mAutoCompleteTextView.post(new Runnable() {
        @Override
        public void run() {
            mInputMethodManager.showSoftInput(mAutoCompleteTextView, InputMethodManager.SHOW_FORCED);
        }
    });
    return true;
}

From source file:org.zywx.wbpalmstar.plugin.inputtextfieldview.ACEInputTextFieldView.java

private void toggleBtnEmojicon(boolean visible) {
    if (visible) {
        if (isKeyBoardVisible) {
            backScroll();/*from  ww  w.  j a  va2  s .co m*/
            mInputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mPagerLayout.setVisibility(View.VISIBLE);
                mEmojiconsLayout.setVisibility(View.VISIBLE);
                mEditText.requestFocus();
            }
        }, 200);
    } else {
        if (!isKeyBoardVisible) {
            mInputManager.toggleSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.SHOW_FORCED,
                    0);
        }
        mEmojiconsLayout.setVisibility(View.GONE);
        mPagerLayout.setVisibility(View.GONE);
    }
}

From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java

private void openSearch(Boolean openKeyboard) {
    this.materialMenu.animateState(IconState.ARROW);
    this.logo.setVisibility(View.GONE);
    this.drawerLogo.setVisibility(View.GONE);
    this.search.setVisibility(View.VISIBLE);
    search.requestFocus();//from   www .j a va2 s .co  m
    this.results.setVisibility(View.VISIBLE);
    animate = true;
    results.setAdapter(new SearchAdapter(context, resultList));
    search.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
                micStateChanged(false);
                mic.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_clear));
                updateResults();
            } else {
                micStateChanged(true);
                mic.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_action_mic));
                if (initialResults != null) {
                    setInitialResults();
                } else {
                    updateResults();
                }
            }

            if (listener != null)
                listener.onSearchTermChanged();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

    });
    results.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            SearchResult result = resultList.get(arg2);
            search(result);

        }

    });
    if (initialResults != null) {
        setInitialResults();
    } else {
        updateResults();
    }

    if (listener != null)
        listener.onSearchOpened();
    if (getSearchText().length() > 0) {
        micStateChanged(false);
        mic.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_clear));
    }
    if (openKeyboard) {
        InputMethodManager inputMethodManager = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.toggleSoftInputFromWindow(getApplicationWindowToken(),
                InputMethodManager.SHOW_FORCED, 0);
    }
}