本文整理汇总了Java中android.view.View.setOnKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.setOnKeyListener方法的具体用法?Java View.setOnKeyListener怎么用?Java View.setOnKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setOnKeyListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newList
import android.view.View; //导入方法依赖的package包/类
private View newList(
final PickerQuery q, final ViewAnimator flip,
AdapterView.OnItemClickListener click) {
final View list = newList(q, click);
list.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK &&
event.getAction() == KeyEvent.ACTION_UP) {
flip.setInAnimation(getContext(), R.anim.slide_in_left);
flip.setOutAnimation(getContext(), R.anim.slide_out_right);
flip.showPrevious();
flip.removeView(list);
flip.setInAnimation(getContext(), R.anim.slide_in_right);
flip.setOutAnimation(getContext(), R.anim.slide_out_left);
return true;
}
return false;
}
});
return list;
}
示例2: setUpBackPresses
import android.view.View; //导入方法依赖的package包/类
private void setUpBackPresses(View view) {
view.setFocusableInTouchMode(true);
view.requestFocus();
view.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
// handle back button's click listener
if (mSearchView.isSearching()) {
mSearchView.closeSearch();
}
return true;
}
return false;
}
});
}
示例3: addToCustomContentPage
import android.view.View; //导入方法依赖的package包/类
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks,
String description) {
if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
throw new RuntimeException("Expected custom content screen to exist");
}
// Add the custom content to the full screen custom page
CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
int spanX = customScreen.getCountX();
int spanY = customScreen.getCountY();
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
lp.canReorder = false;
lp.isFullscreen = true;
if (customContent instanceof Insettable) {
((Insettable)customContent).setInsets(mInsets);
}
// Verify that the child is removed from any existing parent.
if (customContent.getParent() instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) customContent.getParent();
parent.removeView(customContent);
}
customScreen.removeAllViews();
customContent.setFocusable(true);
customContent.setOnKeyListener(new FullscreenKeyEventListener());
customContent.setOnFocusChangeListener(mLauncher.mFocusHandler
.getHideIndicatorOnFocusListener());
customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
mCustomContentDescription = description;
mCustomContentCallbacks = callbacks;
}
示例4: onBindDialogView
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
mSeekBarVolumizer = new SeekBarVolumizer(getContext(), seekBar, mStreamType);
// grab focus and key events so that pressing the volume buttons in the
// dialog doesn't also show the normal volume adjust toast.
view.setOnKeyListener(this);
view.setFocusableInTouchMode(true);
view.requestFocus();
}
示例5: cleanup
import android.view.View; //导入方法依赖的package包/类
/**
* Do clean up. This can be called multiple times!
*/
private void cleanup() {
if (mSeekBarVolumizer != null) {
Dialog dialog = getDialog();
if (dialog != null && dialog.isShowing()) {
View view = dialog.getWindow().getDecorView()
.findViewById(R.id.seekbar);
if (view != null) view.setOnKeyListener(null);
// Stopped while dialog was showing, revert changes
mSeekBarVolumizer.revertVolume();
}
mSeekBarVolumizer.stop();
mSeekBarVolumizer = null;
}
}
示例6: onBackPressed
import android.view.View; //导入方法依赖的package包/类
private void onBackPressed(View view) {
view.setFocusableInTouchMode(true);
view.setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
new AlertDialog.Builder(getActivity())
.setTitle("Leave")
.setMessage("Do you really want to leave this slot? When you leave, your balance in the current slot is automatically cashed out to your wallet.")
.setPositiveButton("Yes", (dialog, id) -> getActivity().finish())
.setNegativeButton("No", null)
.show();
return true;
}
return false;
});
}
示例7: onBackPressed
import android.view.View; //导入方法依赖的package包/类
private void onBackPressed(View view) {
view.setFocusableInTouchMode(true);
view.setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
new AlertDialog.Builder(getActivity())
.setTitle("Leave")
.setMessage("Exit the watch screen?")
.setPositiveButton("Yes", (dialog, id) -> getActivity().finish())
.setNegativeButton("No", null)
.show();
return true;
}
return false;
});
}
示例8: addInScreen
import android.view.View; //导入方法依赖的package包/类
/**
* Adds the specified child in the specified screen. The position and dimension of
* the child are defined by x, y, spanX and spanY.
*
* @param child The child to add in one of the workspace's screens.
* @param screenId The screen in which to add the child.
* @param x The X position of the child in the screen's grid.
* @param y The Y position of the child in the screen's grid.
* @param spanX The number of cells spanned horizontally by the child.
* @param spanY The number of cells spanned vertically by the child.
*/
private void addInScreen(View child, long container, long screenId, int x, int y,
int spanX, int spanY) {
if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
if (getScreenWithId(screenId) == null) {
// DEBUGGING - Print out the stack trace to see where we are adding from
new Throwable().printStackTrace();
return;
}
}
if (screenId == EXTRA_EMPTY_SCREEN_ID) {
// This should never happen
throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
}
final CellLayout layout;
if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
layout = mLauncher.getHotseat().getLayout();
child.setOnKeyListener(new HotseatIconKeyEventListener());
// Hide folder title in the hotseat
if (child instanceof FolderIcon) {
((FolderIcon) child).setTextVisible(false);
}
} else {
// Show folder title if not in the hotseat
if (child instanceof FolderIcon) {
((FolderIcon) child).setTextVisible(true);
}
layout = getScreenWithId(screenId);
child.setOnKeyListener(new IconKeyEventListener());
}
ViewGroup.LayoutParams genericLp = child.getLayoutParams();
CellLayout.LayoutParams lp;
if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
} else {
lp = (CellLayout.LayoutParams) genericLp;
lp.cellX = x;
lp.cellY = y;
lp.cellHSpan = spanX;
lp.cellVSpan = spanY;
}
if (spanX < 0 && spanY < 0) {
lp.isLockedToGrid = false;
}
// Get the canonical child id to uniquely represent this view in this screen
ItemInfo info = (ItemInfo) child.getTag();
int childId = mLauncher.getViewIdForItem(info);
boolean markCellsAsOccupied = !(child instanceof Folder);
if (!layout.addViewToCellLayout(child, -1, childId, lp, markCellsAsOccupied)) {
// TODO: This branch occurs when the workspace is adding views
// outside of the defined grid
// maybe we should be deleting these items from the LauncherModel?
}
if (!(child instanceof Folder)) {
child.setHapticFeedbackEnabled(false);
child.setOnLongClickListener(mLongClickListener);
}
if (child instanceof DropTarget) {
mDragController.addDropTarget((DropTarget) child);
}
}
示例9: onCreateView
import android.view.View; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.dialer_digit, container, false);
// Store the backgrounds objects that will be in use later
/*
Resources r = getResources();
digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal);
*/
// Store some object that could be useful later
digits = (DigitsEditText) v.findViewById(R.id.digitsText);
dialPad = (Dialpad) v.findViewById(R.id.dialPad);
callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar);
autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList);
rewriteTextInfo = (TextView) v.findViewById(R.id.rewriteTextInfo);
accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton);
accountChooserFilterItem = accountChooserButton.addExtraMenuItem(R.string.apply_rewrite);
accountChooserFilterItem.setCheckable(true);
accountChooserFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setRewritingFeature(!accountChooserFilterItem.isChecked());
return true;
}
});
setRewritingFeature(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.REWRITE_RULES_DIALER));
dialerLayout = (DialerLayout) v.findViewById(R.id.top_digit_dialer);
//switchTextView = (ImageButton) v.findViewById(R.id.switchTextView);
// isTablet = Compatibility.isTabletScreen(getActivity());
// Digits field setup
if(savedInstanceState != null) {
isDigit = savedInstanceState.getBoolean(TEXT_MODE_KEY, isDigit);
}
digits.setOnEditorActionListener(keyboardActionListener);
// Layout
dialerLayout.setForceNoList(mDualPane);
dialerLayout.setAutoCompleteListVisibiltyChangedListener(this);
// Account chooser button setup
accountChooserButton.setShowExternals(true);
accountChooserButton.setOnAccountChangeListener(accountButtonChangeListener);
// Dialpad
dialPad.setOnDialKeyListener(this);
// We only need to add the autocomplete list if we
autoCompleteList.setAdapter(autoCompleteAdapter);
autoCompleteList.setOnItemClickListener(autoCompleteListItemListener);
autoCompleteList.setFastScrollEnabled(true);
// Bottom bar setup
callBar.setOnDialActionListener(this);
callBar.setVideoEnabled(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO));
//switchTextView.setVisibility(Compatibility.isCompatible(11) ? View.GONE : View.VISIBLE);
// Init other buttons
initButtons(v);
// Ensure that current mode (text/digit) is applied
setTextDialing(!isDigit, true);
if(initText != null) {
digits.setText(initText);
initText = null;
}
// Apply third party theme if any
applyTheme(v);
v.setOnKeyListener(this);
applyTextToAutoComplete();
return v;
}