List of usage examples for android.view View setLongClickable
public void setLongClickable(boolean longClickable)
From source file:com.facebook.litho.MountState.java
private static void unsetViewAttributes(MountItem item) { final Component<?> component = item.getComponent(); if (!isMountViewSpec(component)) { return;/* w w w. jav a 2s. c o m*/ } final View view = (View) item.getContent(); final NodeInfo nodeInfo = item.getNodeInfo(); if (nodeInfo != null) { if (nodeInfo.getClickHandler() != null) { unsetClickHandler(view); } if (nodeInfo.getLongClickHandler() != null) { unsetLongClickHandler(view); } if (nodeInfo.getTouchHandler() != null) { unsetTouchHandler(view); } if (nodeInfo.getInterceptTouchHandler() != null) { unsetInterceptTouchEventHandler(view); } unsetViewTag(view); unsetViewTags(view, nodeInfo.getViewTags()); if (!TextUtils.isEmpty(nodeInfo.getContentDescription())) { unsetContentDescription(view); } } view.setClickable(MountItem.isViewClickable(item.getFlags())); view.setLongClickable(MountItem.isViewLongClickable(item.getFlags())); unsetFocusable(view, item); if (item.getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_AUTO) { unsetImportantForAccessibility(view); } unsetAccessibilityDelegate(view); final ViewNodeInfo viewNodeInfo = item.getViewNodeInfo(); if (viewNodeInfo != null && !isHostSpec(component)) { unsetViewPadding(view, viewNodeInfo); unsetViewBackground(view, viewNodeInfo); unsetViewForeground(view, viewNodeInfo); unsetViewLayoutDirection(view, viewNodeInfo); } }
From source file:com.tdispatch.passenger.fragment.ControlCenterFragment.java
protected void hideAimPoint() { if (mAimPointVisible) { mAimPointVisible = false;//from www . ja v a 2 s . com View v = mFragmentView.findViewById(R.id.map_aim_point_container); v.clearAnimation(); v.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.fade_out)); WebnetTools.setVisibility(mFragmentView, R.id.map_aim_point_minimal_container, View.VISIBLE); int[] ids = { R.id.button_set_as_pickup, R.id.button_set_as_dropoff }; for (int id : ids) { v = mFragmentView.findViewById(id); v.setClickable(false); v.setLongClickable(false); } } }
From source file:com.tdispatch.passenger.fragment.ControlCenterFragment.java
protected void showAimPoint(Boolean animate) { if (mAimPointVisible == false) { mAimPointVisible = true;//from w w w. j av a2 s .co m View v = mFragmentView.findViewById(R.id.map_aim_point_container); v.clearAnimation(); v.startAnimation( AnimationUtils.loadAnimation(mContext, (animate) ? R.anim.fade_in : R.anim.fade_in_instant)); WebnetTools.setVisibility(mFragmentView, R.id.map_aim_point_minimal_container, View.INVISIBLE); int[] ids = { R.id.button_set_as_pickup, R.id.button_set_as_dropoff }; for (int id : ids) { v = mFragmentView.findViewById(id); v.setClickable(true); v.setLongClickable(true); } } }
From source file:net.czlee.debatekeeper.DebatingActivity.java
/** * Updates the buttons according to the current status of the debate * The buttons are allocated as follows: * When at start: [Start] [Next] * When running: [Stop]/*ww w . j a v a 2s.com*/ * When stopped by user: [Resume] [Restart] [Next] * When stopped by alarm: [Resume] * The [Bell] button always is on the right of any of the above three buttons. */ private void updateControls() { if (mDebateTimerDisplay == null) return; if (mDebateManager != null && mDebateTimerDisplay.getId() == R.id.debateTimer_root) { View currentTimeText = mDebateTimerDisplay.findViewById(R.id.debateTimer_currentTime); View currentTimePicker = mDebateTimerDisplay.findViewById(R.id.debateTimer_currentTimePicker); // If it's the last speaker, don't show a "next speaker" button. // Show a "restart debate" button instead. switch (mDebateManager.getTimerStatus()) { case NOT_STARTED: setButtons(CONTROL_BUTTON_START_TIMER, null, CONTROL_BUTTON_NEXT_PHASE); break; case RUNNING: setButtons(CONTROL_BUTTON_STOP_TIMER, null, null); break; case STOPPED_BY_BELL: setButtons(CONTROL_BUTTON_RESUME_TIMER, null, null); break; case STOPPED_BY_USER: setButtons(CONTROL_BUTTON_RESUME_TIMER, CONTROL_BUTTON_RESET_TIMER, CONTROL_BUTTON_NEXT_PHASE); break; } currentTimeText.setVisibility((mIsEditingTime) ? View.GONE : View.VISIBLE); currentTimePicker.setVisibility((mIsEditingTime) ? View.VISIBLE : View.GONE); setButtonsEnable(!mIsEditingTime); currentTimeText.setLongClickable(!mDebateManager.isRunning()); mViewPager.setPagingEnabled(!mIsEditingTime && !mDebateManager.isRunning()); } else { // If no debate is loaded, show only one control button, which leads the user to // choose a style. (Keep the play bell button enabled.) setButtons(CONTROL_BUTTON_CHOOSE_STYLE, null, null); mLeftControlButton.setEnabled(true); mCentreControlButton.setEnabled(false); mRightControlButton.setEnabled(false); // This seems counter-intuitive, but we enable paging if there is no debate loaded, // as there is only one page anyway, and this way the "scrolled to the limit" // indicators appear on the screen. mViewPager.setPagingEnabled(true); } // Show or hide the [Bell] button updatePlayBellButton(); }
From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java
private View createDictionaryRow(final DictionaryInfo dictionaryInfo, final ViewGroup parent, boolean canLaunch) { View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.dictionary_manager_row, parent, false); final TextView name = (TextView) row.findViewById(R.id.dictionaryName); final TextView details = (TextView) row.findViewById(R.id.dictionaryDetails); name.setText(application.getDictionaryName(dictionaryInfo.uncompressedFilename)); final boolean updateAvailable = application.updateAvailable(dictionaryInfo); final Button downloadButton = (Button) row.findViewById(R.id.downloadButton); final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename); boolean broken = false; if (!dictionaryInfo.isValid()) { broken = true;/*from ww w . j av a2 s . c o m*/ canLaunch = false; } if (downloadable != null && (!canLaunch || updateAvailable)) { downloadButton.setText(getString(R.string.downloadButton, downloadable.zipBytes / 1024.0 / 1024.0)); downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2); downloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton); } }); } else { downloadButton.setVisibility(View.INVISIBLE); } LinearLayout buttons = (LinearLayout) row.findViewById(R.id.dictionaryLauncherButtons); final List<IndexInfo> sortedIndexInfos = application.sortedIndexInfos(dictionaryInfo.indexInfos); final StringBuilder builder = new StringBuilder(); if (updateAvailable) { builder.append(getString(R.string.updateAvailable)); } for (IndexInfo indexInfo : sortedIndexInfos) { final View button = application.createButton(buttons.getContext(), dictionaryInfo, indexInfo); buttons.addView(button); if (canLaunch) { button.setOnClickListener(new IntentLauncher(buttons.getContext(), DictionaryActivity.getLaunchIntent(getApplicationContext(), application.getPath(dictionaryInfo.uncompressedFilename), indexInfo.shortName, ""))); } else { button.setEnabled(false); button.setFocusable(false); } if (builder.length() != 0) { builder.append("; "); } builder.append(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount)); } builder.append("; "); builder.append(getString(R.string.downloadButton, dictionaryInfo.uncompressedBytes / 1024.0 / 1024.0)); if (broken) { name.setText("Broken: " + application.getDictionaryName(dictionaryInfo.uncompressedFilename)); builder.append("; Cannot be used, redownload, check hardware/file system"); // Allow deleting, but cannot open row.setLongClickable(true); } details.setText(builder.toString()); if (canLaunch) { row.setClickable(true); row.setOnClickListener(new IntentLauncher(parent.getContext(), DictionaryActivity.getLaunchIntent(getApplicationContext(), application.getPath(dictionaryInfo.uncompressedFilename), dictionaryInfo.indexInfos.get(0).shortName, ""))); // do not setFocusable, for keyboard navigation // offering only the index buttons is better. row.setLongClickable(true); } row.setBackgroundResource(android.R.drawable.menuitem_background); return row; }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override @TargetApi(11)//w ww . j a v a 2s. c o m public void onCreate(Bundle icicle) { super.onCreate(icicle); if (!InstallMosh.isInstallStarted()) { new InstallMosh(this); } configureStrictMode(); hardKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; hardKeyboard = hardKeyboard && !Build.MODEL.contains("Transformer"); this.setContentView(R.layout.act_console); BugSenseHandler.setup(this, "d27a12dc"); clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); prefs = PreferenceManager.getDefaultSharedPreferences(this); // hide action bar if requested by user try { ActionBar actionBar = getActionBar(); if (!prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { actionBar.hide(); } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); } catch (NoSuchMethodError error) { Log.w(TAG, "Android sdk version pre 11. Not touching ActionBar."); } // 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 requested = getIntent().getData(); inflater = LayoutInflater.from(this); flip = (ViewFlipper) findViewById(R.id.console_flip); 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(); } }); 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(); } }); // preload animations for terminal switching slide_left_in = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); slide_left_out = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); slide_right_in = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slide_right_out = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed); fade_stay_hidden = AnimationUtils.loadAnimation(this, R.anim.fade_stay_hidden); // 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); inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final RelativeLayout keyboardGroup = (RelativeLayout) findViewById(R.id.keyboard_group); if (Build.MODEL.contains("Transformer") && getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY && prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { keyboardGroup.setEnabled(false); keyboardGroup.setVisibility(View.INVISIBLE); } mKeyboardButton = (ImageView) 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 symButton = (ImageView) findViewById(R.id.button_sym); symButton.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.showCharPickerDialog(terminal); keyboardGroup.setVisibility(View.GONE); } }); mInputButton = (ImageView) findViewById(R.id.button_input); mInputButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView ctrlButton = (ImageView) 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); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView escButton = (ImageView) 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(); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); // detect fling gestures to switch between terminals final GestureDetector detect = new GestureDetector(new ICBSimpleOnGestureListener(this)); flip.setLongClickable(true); flip.setOnTouchListener(new ICBOnTouchListener(this, keyboardGroup, detect)); }
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 www. ja v a2 s . c om*/ // 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; }