本文整理了Java中android.widget.ImageButton.setOnLongClickListener()
方法的一些代码示例,展示了ImageButton.setOnLongClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.setOnLongClickListener()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:setOnLongClickListener
暂无
代码示例来源:origin: mthli/Knife
private void setupItalic() {
ImageButton italic = (ImageButton) findViewById(R.id.italic);
italic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.italic(!knife.contains(KnifeText.FORMAT_ITALIC));
}
});
italic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_italic, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupQuote() {
ImageButton quote = (ImageButton) findViewById(R.id.quote);
quote.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.quote(!knife.contains(KnifeText.FORMAT_QUOTE));
}
});
quote.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_quote, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupUnderline() {
ImageButton underline = (ImageButton) findViewById(R.id.underline);
underline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.underline(!knife.contains(KnifeText.FORMAT_UNDERLINED));
}
});
underline.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_underline, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupClear() {
ImageButton clear = (ImageButton) findViewById(R.id.clear);
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.clearFormats();
}
});
clear.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_format_clear, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupBold() {
ImageButton bold = (ImageButton) findViewById(R.id.bold);
bold.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.bold(!knife.contains(KnifeText.FORMAT_BOLD));
}
});
bold.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_bold, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupBullet() {
ImageButton bullet = (ImageButton) findViewById(R.id.bullet);
bullet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.bullet(!knife.contains(KnifeText.FORMAT_BULLET));
}
});
bullet.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_bullet, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupStrikethrough() {
ImageButton strikethrough = (ImageButton) findViewById(R.id.strikethrough);
strikethrough.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
knife.strikethrough(!knife.contains(KnifeText.FORMAT_STRIKETHROUGH));
}
});
strikethrough.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_strikethrough, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: mthli/Knife
private void setupLink() {
ImageButton link = (ImageButton) findViewById(R.id.link);
link.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLinkDialog();
}
});
link.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MainActivity.this, R.string.toast_insert_link, Toast.LENGTH_SHORT).show();
return true;
}
});
}
代码示例来源:origin: fossasia/pslab-android
up.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(final View view) {
down.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(final View view) {
代码示例来源:origin: Calsign/APDE
public void assignLongPressDescription(final ImageButton button, final int descId) {
button.setOnLongClickListener(new ImageButton.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast toast = Toast.makeText(getEditor(), descId, Toast.LENGTH_SHORT);
positionToast(toast, button, getEditor().getWindow(), 0, 0);
toast.show();
return true;
}
});
}
代码示例来源:origin: cenkgun/ChatBar
public void setOnMicListener(final OnLongClickListener listener) {
sendButton.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (messageEditText.getText().length() == 0) {
listener.onLongClick(view);
}
return true;
}
});
}
代码示例来源:origin: stackoverflow.com
ImageButton button = (ImageButton) findViewById(R.id.img_button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
button.setImageResource(R.drawable.pic1);
}
});
button.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
button.setImageResource(R.drawable.pic2);
return true; // <-- This must be true.
}
});
代码示例来源:origin: stackoverflow.com
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_menu, menu);
final MenuItem item1= menu.findItem(R.id.item1);
MenuItemCompat.setActionView(item1, R.layout.custom_action_view);
View vItem1= MenuItemCompat.getActionView(item1);
final ImageButton customActionItem= (ImageButton) vItem1.findViewById(R.id.customActionItem);
customActionItem.setOnLongClickListener(new OnLongClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// do something here
}
});
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: stackoverflow.com
ImageButton imageButton;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageButton = (ImageButton) findViewById(R.id.img_btn1);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageButton.setImageResource(R.drawable.imga);
}
});
imageButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
imageButton.setImageResource(R.drawable.imgb);
return true;
}
});
}
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateActionView() {
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
View view = layoutInflater.inflate(R.layout.action_bar_custom_action_provider, null);
ImageButton button = (ImageButton) view.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Respond to normal click
}
});
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// Respond to long-click
return true;
}
}
return view;
}
代码示例来源:origin: philliphsu/NumberPadTimePicker
/**
* @param presenter The presenter to forward click events to.
*/
private void setupClickListeners(INumberPadTimePicker.Presenter presenter) {
OnBackspaceClickHandler backspaceClickHandler = new OnBackspaceClickHandler(presenter);
mTimePickerComponent.mBackspace.setOnClickListener(backspaceClickHandler);
mTimePickerComponent.mBackspace.setOnLongClickListener(backspaceClickHandler);
mTimePickerComponent.mNumberPad.setOnNumberKeyClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.onNumberKeyClick(((TextView) v).getText());
}
});
mTimePickerComponent.mNumberPad.setOnAltKeyClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.onAltKeyClick(((TextView) v).getText());
}
});
}
代码示例来源:origin: stackoverflow.com
ImageButton iBtn = new ImageButton(this);
iBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iBtn.setImageDrawable(getResources().getDrawable(R.drawable.img1);
}
});
iBtn.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
iBtn.setImageDrawable(getResources().getDrawable(R.drawable.img2);
return true;
}
});
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
@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);
}
代码示例来源:origin: com.willowtreeapps/oak-demos
@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);
}
代码示例来源:origin: derry/delion
@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);
}
内容来源于网络,如有侵权,请联系作者删除!