本文整理汇总了Java中android.widget.ImageButton.setOnLongClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setOnLongClickListener方法的具体用法?Java ImageButton.setOnLongClickListener怎么用?Java ImageButton.setOnLongClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageButton
的用法示例。
在下文中一共展示了ImageButton.setOnLongClickListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFinishInflate
import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
super.onFinishInflate();
setBackground(new ColorDrawable(
ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color)));
mUrlBar = (UrlBar) findViewById(R.id.url_bar);
mUrlBar.setHint("");
mUrlBar.setDelegate(this);
mUrlBar.setEnabled(false);
mUrlBar.setAllowFocus(false);
mTitleBar = (TextView) findViewById(R.id.title_bar);
mLocationBarFrameLayout = findViewById(R.id.location_bar_frame_layout);
mTitleUrlContainer = findViewById(R.id.title_url_container);
mTitleUrlContainer.setOnLongClickListener(this);
mSecurityButton = (TintedImageButton) findViewById(R.id.security_button);
mSecurityIconType = ConnectionSecurityLevel.NONE;
mCustomActionButton = (ImageButton) findViewById(R.id.action_button);
mCustomActionButton.setOnLongClickListener(this);
mCloseButton = (ImageButton) findViewById(R.id.close_button);
mCloseButton.setOnLongClickListener(this);
mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer);
}
示例2: onBindView
import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onBindView(View view) {
super.onBindView(view);
LinearLayout widgetFrameView = ((LinearLayout) view.findViewById(android.R.id.widget_frame));
mBtnAppIcon = new ImageButton(mContext);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mAppIconPreviewSizePx, mAppIconPreviewSizePx);
lp.gravity = Gravity.CENTER;
mBtnAppIcon.setLayoutParams(lp);
mBtnAppIcon.setScaleType(ScaleType.CENTER_CROP);
mBtnAppIcon.setImageDrawable(mAppInfo.icon);
mBtnAppIcon.setFocusable(false);
if (mIconPickerEnabled) {
mBtnAppIcon.setOnClickListener(this);
mBtnAppIcon.setOnLongClickListener(this);
} else {
mBtnAppIcon.setEnabled(false);
}
widgetFrameView.addView(mBtnAppIcon);
widgetFrameView.setVisibility(View.VISIBLE);
}
示例3: attachButtonListener
import android.widget.ImageButton; //导入方法依赖的package包/类
private void attachButtonListener(View v, int id, boolean longAttach) {
ImageButton button = (ImageButton) v.findViewById(id);
if(button == null) {
Log.w(THIS_FILE, "Not found button " + id);
return;
}
if(longAttach) {
button.setOnLongClickListener(this);
}else {
button.setOnClickListener(this);
}
}
示例4: onFinishInflate
import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
public void onFinishInflate() {
mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
mImageButton.setOnClickListener(this);
mTextButton.setOnClickListener(this);
mImageButton.setOnLongClickListener(this);
setOnClickListener(this);
setOnLongClickListener(this);
}
示例5: getMenuItemView
import android.widget.ImageButton; //导入方法依赖的package包/类
private View getMenuItemView(MenuItem item) {
final ImageButton button = new ImageButton(context);
button.setImageDrawable(item.getIcon());
button.setBackgroundResource(R.drawable.toolbar_button);
button.setId(item.getItemId());
button.setLayoutParams(new LayoutParams(itemWidth,
ViewGroup.LayoutParams.MATCH_PARENT));
button.setOnClickListener(this);
button.setOnLongClickListener(this);
return button;
}
示例6: buildBottomBarButton
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* Builds an {@link ImageButton} from the data in this params. Generated buttons should be
* placed on the bottom bar. The button's tag will be its id.
* @param parent The parent that the inflated {@link ImageButton}.
* @param listener {@link OnClickListener} that should be used with the button.
* @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid.
*/
ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) {
if (mIsOnToolbar) return null;
ImageButton button = (ImageButton) LayoutInflater.from(context)
.inflate(R.layout.custom_tabs_bottombar_item, parent, false);
button.setId(mId);
button.setImageBitmap(mIcon);
button.setContentDescription(mDescription);
if (mPendingIntent == null) {
button.setEnabled(false);
} else {
button.setOnClickListener(listener);
}
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
final int screenWidth = view.getResources().getDisplayMetrics().widthPixels;
final int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final int width = view.getWidth();
Toast toast = Toast.makeText(
view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM | Gravity.END,
screenWidth - screenPos[0] - width / 2,
screenHeight - screenPos[1]);
toast.show();
return true;
}
});
return button;
}
示例7: DialogImageSettings
import android.widget.ImageButton; //导入方法依赖的package包/类
public DialogImageSettings(AppCompatActivity activity, ImagePropertiesChangeIf changeIf, ImageProperties parameters)
{
super(activity, R.layout.dialog_image_settings, R.string.dialog_image_settings_title);
this.activity = activity;
this.parameters = parameters;
fileName = (EditText) findViewById(R.id.dialog_file_name);
if (parameters.fileName != null)
{
fileName.setText(parameters.fileName);
}
buttonSelectFile = (ImageButton) findViewById(R.id.dialog_button_select_file);
buttonSelectFile.setOnClickListener(this);
buttonSelectFile.setOnLongClickListener(this);
ViewUtils.setImageButtonColorAttr(activity, buttonSelectFile, R.attr.colorDialogContent);
cbEmbedded = (CheckBox) findViewById(R.id.dialog_checkbox_embedded);
cbEmbedded.setChecked(parameters.embedded);
pickerWidth = (HorizontalNumberPicker) findViewById(R.id.dialog_picker_width);
pickerWidth.setValue(parameters.width);
pickerWidth.minValue = 0;
pickerHeight = (HorizontalNumberPicker) findViewById(R.id.dialog_picker_height);
pickerHeight.setValue(parameters.height);
pickerHeight.minValue = 0;
rOriginalSize = (RadioButton) findViewById(R.id.dialog_button_original_size);
rOriginalSize.setOnClickListener(this);
rOriginalSize.setChecked(parameters.originalSize);
rCustomSize = (RadioButton) findViewById(R.id.dialog_button_custom_size);
rCustomSize.setOnClickListener(this);
rCustomSize.setChecked(!parameters.originalSize);
onClick(parameters.originalSize ? rOriginalSize : rCustomSize);
this.changeIf = changeIf;
}
示例8: prepare
import android.widget.ImageButton; //导入方法依赖的package包/类
private void prepare(AttributeSet attrs)
{
setBaselineAligned(false);
setVerticalGravity(Gravity.CENTER_VERTICAL);
setOrientation(HORIZONTAL);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.horizontal_number_picker, this);
editText = ((EditText) findViewById(R.id.edit_text_value));
if (attrs != null)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.HorizontalNumberPicker, 0, 0);
CharSequence label = a.getText(R.styleable.HorizontalNumberPicker_label);
if (label != null)
{
((TextView) findViewById(R.id.label_text)).setText(label);
}
editText.setMinimumWidth(a.getDimensionPixelSize(R.styleable.HorizontalNumberPicker_minWidth, 0));
a.recycle();
}
bDecrease = (ImageButton) findViewById(R.id.button_decrease);
bDecrease.setOnClickListener(this);
bDecrease.setOnLongClickListener(this);
updateViewColor(bDecrease);
bIncrease = (ImageButton) findViewById(R.id.button_increase);
bIncrease.setOnClickListener(this);
bIncrease.setOnLongClickListener(this);
updateViewColor(bIncrease);
description = (TextView) findViewById(R.id.label_text);
}
示例9: DialogLineSettings
import android.widget.ImageButton; //导入方法依赖的package包/类
public DialogLineSettings(Activity context, LinePropertiesChangeIf changeIf, LineProperties parameters)
{
super(context, R.layout.dialog_line_settings, R.string.dialog_line_settings_title);
this.parameters = parameters;
widthPicker = (HorizontalNumberPicker) findViewById(R.id.dialog_number_picker);
widthPicker.setValue(parameters.width);
widthPicker.minValue = 1;
colorPicker = PrepareColorPicker(parameters.color);
radioButtons = new RadioButton[4];
radioButtons[0] = (RadioButton) findViewById(R.id.dialog_button_line_style_solid);
radioButtons[1] = (RadioButton) findViewById(R.id.dialog_button_line_style_dotted);
radioButtons[2] = (RadioButton) findViewById(R.id.dialog_button_line_style_dashed);
radioButtons[3] = (RadioButton) findViewById(R.id.dialog_button_line_style_dash_dot);
radioLines = new CustomTextView[radioButtons.length];
radioLines[0] = (CustomTextView) findViewById(R.id.dialog_marker_line_style_solid);
radioLines[1] = (CustomTextView) findViewById(R.id.dialog_marker_line_style_dotted);
radioLines[2] = (CustomTextView) findViewById(R.id.dialog_marker_line_style_dashed);
radioLines[3] = (CustomTextView) findViewById(R.id.dialog_marker_line_style_dash_dot);
LineProperties l = new LineProperties();
l.color = CompatUtils.getThemeColorAttr(getContext(), R.attr.colorDialogContent);
l.width = ViewUtils.dpToPx(getContext().getResources().getDisplayMetrics(), 2);
for (int i = 0; i < radioButtons.length; i++)
{
l.lineStyle = LineProperties.LineStyle.values()[i];
l.preparePaint();
radioLines[i].setExternalPaint(l.getPaint());
radioLines[i].setOnClickListener(this);
radioButtons[i].setChecked(l.lineStyle == parameters.lineStyle);
radioButtons[i].setOnClickListener(this);
}
pointShapesBox = (CheckBox) findViewById(R.id.dialog_plot_point_shapes);
pointShapesBox.setOnClickListener(this);
pointShapesBox.setChecked(parameters.shapeType != LineProperties.ShapeType.NONE);
shapeSizePicker = (HorizontalNumberPicker) findViewById(R.id.dialog_plot_point_shape_size);
shapeSizePicker.setValue(parameters.shapeSize);
shapeSizePicker.minValue = 100;
shapeSizePicker.setEnabled(pointShapesBox.isChecked());
shapeTypeButtons
.put(LineProperties.ShapeType.SQUARE, (ImageButton) findViewById(R.id.dialog_plot_point_square));
shapeTypeButtons
.put(LineProperties.ShapeType.CIRCLE, (ImageButton) findViewById(R.id.dialog_plot_point_circle));
shapeTypeButtons.put(LineProperties.ShapeType.DIAMOND,
(ImageButton) findViewById(R.id.dialog_plot_point_diamond));
shapeTypeButtons.put(LineProperties.ShapeType.CROSS, (ImageButton) findViewById(R.id.dialog_plot_point_cross));
for (Map.Entry<LineProperties.ShapeType, ImageButton> e : shapeTypeButtons.entrySet())
{
ImageButton b = e.getValue();
b.setOnClickListener(this);
b.setOnLongClickListener(this);
setButtonEnabled(b, pointShapesBox.isChecked());
if (b.isEnabled())
{
setButtonSelected(b, e.getKey() == parameters.shapeType);
}
}
this.changeIf = changeIf;
}