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.NavFragments.FragmentSearch.java

private void InitiateSearch() {
    card_search.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override/*from   w w w  .  j a  v  a2 s  .c  o  m*/
        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);
            }
        }
    });
}

From source file:com.z299studio.pb.HomeActivity.java

private void popInput() {
    if (mPwdEdit != null) {
        mPwdEdit.postDelayed(new Runnable() {
            @Override/* w w  w.j a v a2s  .  co m*/
            public void run() {
                mPwdEdit.requestFocus();
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(mPwdEdit, InputMethodManager.SHOW_FORCED);
            }
        }, 100);

        OnEditorActionListener eal = new OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView edit, int id, KeyEvent event) {
                if (id == EditorInfo.IME_ACTION_DONE) {
                    onConfirm(null);
                    return true;
                }
                return false;
            }
        };
        EditText et_confirm = (EditText) findViewById(R.id.confirm);
        if (et_confirm.getVisibility() == View.VISIBLE) {
            mPwdEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            et_confirm.setOnEditorActionListener(eal);
        } else {
            mPwdEdit.setOnEditorActionListener(eal);
        }
    }
}

From source file:org.tigase.messenger.phone.pro.conversations.chat.ChatItemFragment.java

public void openIME() {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

    imm.showSoftInput(message, InputMethodManager.SHOW_FORCED);
}

From source file:com.amberfog.countryflagsdemo.BaseFlagFragment.java

protected void showKeyboard(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getApplicationContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

From source file:org.mercycorps.translationcards.activity.RecordingActivity.java

private void setFieldBasedOnFocus(boolean hasFocus, EditText field, int hintText) {
    if (hasFocus && field.getText().toString().equals(getString(hintText))) {
        field.setText("");
        field.setTextColor(Color.BLACK);
    } else if (!hasFocus && field.getText().toString().trim().isEmpty()) {
        field.setHint(hintText);/*from   w w w. ja v  a2 s. c  om*/
    }
    if (hasFocus) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        inputMethodManager.toggleSoftInputFromWindow(field.getApplicationWindowToken(),
                InputMethodManager.SHOW_FORCED, 0);
    }
}

From source file:com.nttec.everychan.ui.NewTabFragment.java

private void showKeyboard(View v) {
    try {/* www.ja  va 2 s .c om*/
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                .toggleSoftInputFromWindow(v.getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
    } catch (Exception e) {
        Logger.e(TAG, e);
    }
}

From source file:com.anton.gavel.GavelMain.java

public void createDialog(int id) {
    if (progressDialog != null) {
        progressDialog.dismiss();/*w w w. j  a  va  2s  .  c  o  m*/
    }
    // handles creation of any dialogs by other actions
    switch (id) {
    case DIALOG_PI:
        //call custom dialog for collecting Personal Info
        PersonalInfoDialogFragment personalInfoDialog = new PersonalInfoDialogFragment();
        personalInfoDialog.setPersonalInfo(mPersonalInfo);
        personalInfoDialog.show(getSupportFragmentManager(), "PersonalInfoDialogFragment");
        break;
    case DIALOG_ABOUT:
        //construct a simple dialog to show text

        //get about text
        TextView aboutView = new TextView(this);
        aboutView.setText(R.string.about_text);
        aboutView.setMovementMethod(LinkMovementMethod.getInstance());//enable links
        aboutView.setPadding(50, 30, 50, 30);

        //build dialog
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
        alertDialog.setTitle("About")//title
                .setView(aboutView)//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).create() //build
                .show(); //display
        break;

    case DIALOG_SUBMISSION_ERR:
        AlertDialog.Builder submissionErrorDialog = new AlertDialog.Builder(this);
        submissionErrorDialog.setTitle("Submission Error")//title
                .setMessage("There was a problem submitting your complaint on the City's website.")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;

    case DIALOG_OTHER_COMPLAINT:
        final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_CLASS_TEXT);
        // capitalize letters + seperate words
        AlertDialog.Builder getComplaintDialog = new AlertDialog.Builder(this);
        getComplaintDialog.setTitle("Other...").setView(input)
                .setMessage("Give a categorical title for your complaint:")
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String value = input.getText().toString();
                        // add the item to list and make it selected
                        complaintsAdapter.insert(value, 0);
                        complaintSpinner.setSelection(0);
                        complaintsAdapter.notifyDataSetChanged();
                        addToSubmitValues(value);

                        imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard   
                        dialog.cancel();

                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard              
                        dialog.cancel();
                    }
                }).create();

        input.requestFocus();
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);// show keyboard

        getComplaintDialog.show();//show dialog
        break;
    case DIALOG_NO_GEOCODING:
        AlertDialog.Builder noGeoCoding = new AlertDialog.Builder(this);
        noGeoCoding.setTitle("Not Available")//title
                .setMessage(
                        "Your version of Android does not support location-based address lookup. This feature is only supported on Gingerbread and above.")//insert textview from above
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;
    case DIALOG_INCOMPLETE_PERSONAL_INFORMATION:
        AlertDialog.Builder incompleteInfo = new AlertDialog.Builder(this);
        incompleteInfo.setTitle("Incomplete")//title
                .setMessage(
                        "Your personal information is incomplete. Select 'Edit Personal Information' from the menu and fill in all required fields")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display         
        break;
    case DIALOG_NO_COMPLAINT:
        AlertDialog.Builder noComplaint = new AlertDialog.Builder(this);
        noComplaint.setTitle("No Comlaint Specified")//title
                .setMessage("You must specify a complaint (e.g. barking dog).")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;
    case DIALOG_NO_LOCATION:
        AlertDialog.Builder incompleteComplaint = new AlertDialog.Builder(this);
        incompleteComplaint.setTitle("No Location Specified")//title
                .setMessage("You must specify a location (approximate street address) of the complaint.")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display         
    }

}

From source file:org.connectbot.ConsoleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.frg_console, container, false);

    this.inflater = inflater;

    flip = (ViewFlipper) v.findViewById(R.id.console_flip);
    empty = (TextView) v.findViewById(android.R.id.empty);

    stringPromptGroup = (RelativeLayout) v.findViewById(R.id.console_password_group);
    stringPromptInstructions = (TextView) v.findViewById(R.id.console_password_instructions);
    stringPrompt = (EditText) v.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);/*from   w  ww  . j  a v  a2 s. com*/

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

            return true;
        }
    });

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

    booleanYes = (Button) v.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();
        }
    });

    booleanNo = (Button) v.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();
        }
    });

    // preload animations for terminal switching
    slide_left_in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_left_in);
    slide_left_out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_left_out);
    slide_right_in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_right_in);
    slide_right_out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_right_out);

    fade_out_delayed = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out_delayed);
    fade_stay_hidden = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_stay_hidden);

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

    inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);

    final RelativeLayout keyboardGroup = (RelativeLayout) v.findViewById(R.id.keyboard_group);

    mKeyboardButton = (ImageView) v.findViewById(R.id.button_keyboard);
    mKeyboardButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;

            inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED);
            keyboardGroup.setVisibility(View.GONE);
        }
    });

    final ImageView ctrlButton = (ImageView) v.findViewById(R.id.button_ctrl);
    ctrlButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;
            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.metaPress(TerminalKeyListener.META_CTRL_ON);

            keyboardGroup.setVisibility(View.GONE);
        }
    });

    final ImageView escButton = (ImageView) v.findViewById(R.id.button_esc);
    escButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;
            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.sendEscape();

            keyboardGroup.setVisibility(View.GONE);
        }
    });

    // detect fling gestures to switch between terminals
    final GestureDetector detect = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
        private float totalY = 0;

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {

            final float distx = e2.getRawX() - e1.getRawX();
            final float disty = e2.getRawY() - e1.getRawY();
            final int goalwidth = flip.getWidth() / 2;

            // need to slide across half of display to trigger console change
            // make sure user kept a steady hand horizontally
            if (Math.abs(disty) < (flip.getHeight() / 4)) {
                if (distx > goalwidth) {
                    shiftCurrentTerminal(SHIFT_RIGHT);
                    return true;
                }

                if (distx < -goalwidth) {
                    shiftCurrentTerminal(SHIFT_LEFT);
                    return true;
                }

            }

            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

            // if copying, then ignore
            if (copySource != null && copySource.isSelectingForCopy())
                return false;

            if (e1 == null || e2 == null)
                return false;

            // if releasing then reset total scroll
            if (e2.getAction() == MotionEvent.ACTION_UP) {
                totalY = 0;
            }

            // activate consider if within x tolerance
            if (Math.abs(e1.getX() - e2.getX()) < ViewConfiguration.getTouchSlop() * 4) {

                View flip = findCurrentView(R.id.console_flip);
                if (flip == null)
                    return false;
                TerminalView terminal = (TerminalView) flip;

                // estimate how many rows we have scrolled through
                // accumulate distance that doesn't trigger immediate scroll
                totalY += distanceY;
                final int moved = (int) (totalY / terminal.bridge.charHeight);

                // consume as scrollback only if towards right half of screen
                if (e2.getX() > flip.getWidth() / 2) {
                    if (moved != 0) {
                        int base = terminal.bridge.buffer.getWindowBase();
                        terminal.bridge.buffer.setWindowBase(base + moved);
                        totalY = 0;
                        return true;
                    }
                } else {
                    // otherwise consume as pgup/pgdown for every 5 lines
                    if (moved > 5) {
                        ((vt320) terminal.bridge.buffer).keyPressed(vt320.KEY_PAGE_DOWN, ' ', 0);
                        terminal.bridge.tryKeyVibrate();
                        totalY = 0;
                        return true;
                    } else if (moved < -5) {
                        ((vt320) terminal.bridge.buffer).keyPressed(vt320.KEY_PAGE_UP, ' ', 0);
                        terminal.bridge.tryKeyVibrate();
                        totalY = 0;
                        return true;
                    }

                }

            }

            return false;
        }

    });

    flip.setLongClickable(true);
    flip.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {

            // when copying, highlight the area
            if (copySource != null && copySource.isSelectingForCopy()) {
                int row = (int) Math.floor(event.getY() / copySource.charHeight);
                int col = (int) Math.floor(event.getX() / copySource.charWidth);

                SelectionArea area = copySource.getSelectionArea();

                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    // recording starting area
                    if (area.isSelectingOrigin()) {
                        area.setRow(row);
                        area.setColumn(col);
                        lastTouchRow = row;
                        lastTouchCol = col;
                        copySource.redraw();
                    }
                    return true;
                case MotionEvent.ACTION_MOVE:
                    /* ignore when user hasn't moved since last time so
                     * we can fine-tune with directional pad
                     */
                    if (row == lastTouchRow && col == lastTouchCol)
                        return true;

                    // if the user moves, start the selection for other corner
                    area.finishSelectingOrigin();

                    // update selected area
                    area.setRow(row);
                    area.setColumn(col);
                    lastTouchRow = row;
                    lastTouchCol = col;
                    copySource.redraw();
                    return true;
                case MotionEvent.ACTION_UP:
                    /* If they didn't move their finger, maybe they meant to
                     * select the rest of the text with the directional pad.
                     */
                    if (area.getLeft() == area.getRight() && area.getTop() == area.getBottom()) {
                        return true;
                    }

                    // copy selected area to clipboard
                    String copiedText = area.copyFrom(copySource.buffer);

                    clipboard.setText(copiedText);
                    Toast.makeText(getActivity(), getString(R.string.console_copy_done, copiedText.length()),
                            Toast.LENGTH_LONG).show();
                    // fall through to clear state

                case MotionEvent.ACTION_CANCEL:
                    // make sure we clear any highlighted area
                    area.reset();
                    copySource.setSelectingForCopy(false);
                    copySource.redraw();
                    return true;
                }
            }

            Configuration config = getResources().getConfiguration();

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                lastX = event.getX();
                lastY = event.getY();
            } else if (event.getAction() == MotionEvent.ACTION_UP && keyboardGroup.getVisibility() == View.GONE
                    && event.getEventTime() - event.getDownTime() < CLICK_TIME
                    && Math.abs(event.getX() - lastX) < MAX_CLICK_DISTANCE
                    && Math.abs(event.getY() - lastY) < MAX_CLICK_DISTANCE) {
                keyboardGroup.startAnimation(keyboard_fade_in);
                keyboardGroup.setVisibility(View.VISIBLE);

                mUIHandler.postDelayed(new Runnable() {
                    public void run() {
                        if (keyboardGroup.getVisibility() == View.GONE)
                            return;

                        keyboardGroup.startAnimation(keyboard_fade_out);
                        keyboardGroup.setVisibility(View.GONE);
                    }
                }, KEYBOARD_DISPLAY_TIME);
            }

            // pass any touch events back to detector
            return detect.onTouchEvent(event);
        }

    });

    return v;
}

From source file:com.klinker.android.twitter.ui.compose.Compose.java

public void setUpSimilar() {
    attachImage[0] = (ImageView) findViewById(R.id.picture1);
    attachImage[1] = (ImageView) findViewById(R.id.picture2);
    attachImage[2] = (ImageView) findViewById(R.id.picture3);
    attachImage[3] = (ImageView) findViewById(R.id.picture4);
    attachButton = (ImageButton) findViewById(R.id.attach);
    emojiButton = (ImageButton) findViewById(R.id.emoji);
    emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard);
    reply = (EditText) findViewById(R.id.tweet_content);
    charRemaining = (TextView) findViewById(R.id.char_remaining);

    findViewById(R.id.prompt_pos).setOnClickListener(new View.OnClickListener() {
        @Override/* w  w  w  .  j  a v  a2s . c o m*/
        public void onClick(View v) {
            Log.v("talon_input", "clicked the view");
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(reply,
                    InputMethodManager.SHOW_FORCED);
        }
    });

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.myProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.myProfilePicUrl, false, null);
    }
    currentName.setText("@" + settings.myScreenName);

    //numberAttached.setText("0 " + getString(R.string.attached_images));

    charRemaining.setText(140 - reply.getText().length() + "");

    reply.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            countHandler.removeCallbacks(getCount);
            countHandler.postDelayed(getCount, 300);
        }
    });
}

From source file:com.klinker.android.twitter.activities.compose.Compose.java

public void setUpSimilar() {
    attachImage[0] = (ImageView) findViewById(R.id.picture1);
    attachImage[1] = (ImageView) findViewById(R.id.picture2);
    attachImage[2] = (ImageView) findViewById(R.id.picture3);
    attachImage[3] = (ImageView) findViewById(R.id.picture4);
    attachButton = (ImageButton) findViewById(R.id.attach);
    gifButton = (ImageButton) findViewById(R.id.gif);
    emojiButton = (ImageButton) findViewById(R.id.emoji);
    emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard);
    reply = (EditText) findViewById(R.id.tweet_content);
    charRemaining = (TextView) findViewById(R.id.char_remaining);

    findViewById(R.id.prompt_pos).setOnClickListener(new View.OnClickListener() {
        @Override//from w ww.  j  a v a  2 s . c  om
        public void onClick(View v) {
            Log.v("talon_input", "clicked the view");
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(reply,
                    InputMethodManager.SHOW_FORCED);
        }
    });

    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);

    if (settings.roundContactImages) {
        pic.loadImage(settings.myProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.myProfilePicUrl, false, null);
    }
    currentName.setText("@" + settings.myScreenName);

    //numberAttached.setText("0 " + getString(R.string.attached_images));

    charRemaining.setText(140 - reply.getText().length() + "");

    reply.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            countHandler.removeCallbacks(getCount);
            countHandler.postDelayed(getCount, 300);
        }
    });
}