本文整理了Java中android.widget.ImageButton.getId()
方法的一些代码示例,展示了ImageButton.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.getId()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:getId
暂无
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onClick(View view) {
if (player == null) return;
if (view.getId() == repeatButton.getId()) {
player.onRepeatClicked();
} else if (view.getId() == backwardButton.getId()) {
player.onPlayPrevious();
} else if (view.getId() == playPauseButton.getId()) {
player.onPlayPause();
} else if (view.getId() == forwardButton.getId()) {
player.onPlayNext();
} else if (view.getId() == shuffleButton.getId()) {
player.onShuffleClicked();
} else if (view.getId() == playbackSpeedButton.getId()) {
openPlaybackParameterDialog();
} else if (view.getId() == playbackPitchButton.getId()) {
openPlaybackParameterDialog();
} else if (view.getId() == metadata.getId()) {
scrollToSelected();
} else if (view.getId() == progressLiveSync.getId()) {
player.seekToDefault();
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onClick(View v) {
super.onClick(v);
if (v.getId() == playPauseButton.getId()) {
onPlayPause();
} else if (v.getId() == playPreviousButton.getId()) {
onPlayPrevious();
} else if (v.getId() == playNextButton.getId()) {
onPlayNext();
} else if (v.getId() == queueButton.getId()) {
onQueueClicked();
return;
} else if (v.getId() == repeatButton.getId()) {
onRepeatClicked();
return;
} else if (v.getId() == shuffleButton.getId()) {
onShuffleClicked();
return;
} else if (v.getId() == moreOptionsButton.getId()) {
onMoreOptionsClicked();
} else if (v.getId() == toggleOrientationButton.getId()) {
onScreenRotationClicked();
} else if (v.getId() == switchPopupButton.getId()) {
onFullScreenButtonClicked();
代码示例来源:origin: ybonnel/TransportsRennes
@Override
public void changeIconActionBar(ImageButton imageButton) {
if (imageButton.getId() == R.id.menu_order) {
imageButton.setImageResource(orderDirection ? android.R.drawable.ic_menu_sort_alphabetically
: android.R.drawable.ic_menu_sort_by_size);
}
}
代码示例来源:origin: stackoverflow.com
public static class TextViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView newsTitle, newsBody;
public ImageButton arrowbutton;
public TextViewHolder (final View newsView) {
super(newsView);
newsTitle = (TextView) newsView.findViewById(R.id.news_title);
newsBody = (TextView) newsView.findViewById(R.id.news_body);
arrowbutton = (ImageButton) newsView.findViewById(R.id.arrow_button);
arrowbutton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId() == arrowbutton.getId()) {
int visibilty = news_body.getVisibility();
if (visibilty == View.VISIBLE) {
news_body.setVisibility(View.GONE);
} else {
news_body.setVisibility(View.VISIBLE);
}
}
}
}
代码示例来源:origin: stackoverflow.com
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
LayoutInflater inflater = LayoutInflater.from(getActivity());
View view = inflater.inflate(R.layout.palette, null, false);
ImageButton bnColor;
if(bnColor == null)
{
LinearLayout drawLayout = (LinearLayout) view.findViewById(R.id.paint_colors);
if(savedInstanceState!=null)
bnColor= (ImageButton) getResources().getLayout(savedInstanceState.getInt("color"));
else
bnColor = (ImageButton) drawLayout.getChildAt(0);
bnColor.setImageDrawable(getResources().getDrawable(R.drawable.button_pressed));
}
int value= bnColor.getId();
savedInstanceState.putInt("color", value);
onSaveInstanceState(savedInstanceState);
}
代码示例来源:origin: stackoverflow.com
for (int i =0;i<adapt_objmenu.image_array.length;i++){
ImageButton b1 = new ImageButton(myrefmenu);
b1.setId(100 + i);
b1.setImageResource(R.drawable.imagename);
// b1.setText(adapt_objmenu.city_name_array[i]);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (i > 0) {
lp.addRule(RelativeLayout.RIGHT_OF, b1.getId() - 1);
}
b1.setLayoutParams(lp);
relative.addView(b1);
//relate.addView(b1, i, new RelativeLayout.LayoutParams(width,height));
//height = height+80;
}
代码示例来源:origin: stackoverflow.com
RelativeLayout parent = (RelativeLayout)findViewById(R.id.parent);
ImageButton ib = new ImageButton(getApplicationContext());
ib.setId(1);
ib.setBackgroundResource(R.drawable.cross_button);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ib.setLayoutParams(lp);
parent.addView(ib);
ImageView iv = new ImageView(getApplicationContext());
iv.setBackgroundResource(R.drawable.myshape);
iv.setImageResource(R.drawable.ic_launcher);
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(50,50);
lp1.addRule(RelativeLayout.RIGHT_OF, ib.getId());
lp1.addRule(RelativeLayout.BELOW, ib.getId());
iv.setLayoutParams(lp1);
parent.addView(iv);
代码示例来源:origin: stackoverflow.com
for (int i = 0; i < 50; i++) {
ImageButton b1 = new ImageButton(myrefmenu);
b1.setId(100 + i);
b1.setImageResource(R.drawable.imagename);
// b1.setText(adapt_objmenu.city_name_array[i]);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (i > 0) {
lp.addRule(RelativeLayout.RIGHT_OF, b1.getId() - 1);
}
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(AllbuttonimagesForSelectionActivity.this,
"ImageButton is clicked!", Toast.LENGTH_SHORT)
.show();
}
});
b1.setLayoutParams(lp);
relative.addView(b1);
}
代码示例来源:origin: stackoverflow.com
RelativeLayout rlLayout = (RelativeLayout) findViewById(R.id.parent);
LinearLayout container = new LinearLayout(this);
for (int i = 0; i < 5; i++) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ImageButton ib = new ImageButton(this);
ib.setId(i);
ib.setLayoutParams(layoutParams);
ib.setBackgroundResource(R.drawable.ic_launcher);
container.addView(ib);
if (ib.getId() == position) {
ib.setBackgroundResource(R.drawable.black_circle_32x32);
}
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL,
RelativeLayout.TRUE);
rlLayout.addView(container, layoutParams);
代码示例来源:origin: GeoODK/collect
/**
* This adds a divider at the bottom of this layout. Used to separate fields in lists.
*
* @param v
*/
public void addDivider(ImageView v) {
RelativeLayout.LayoutParams dividerParams =
new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
if (mImageView != null) {
dividerParams.addRule(RelativeLayout.BELOW, mImageView.getId());
} else if (mMissingImage != null) {
dividerParams.addRule(RelativeLayout.BELOW, mMissingImage.getId());
} else if (mVideoButton != null) {
dividerParams.addRule(RelativeLayout.BELOW, mVideoButton.getId());
} else if (mAudioButton != null) {
dividerParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
} else if (mView_Text != null) {
// No picture
dividerParams.addRule(RelativeLayout.BELOW, mView_Text.getId());
} else {
Log.e(t, "Tried to add divider to uninitialized ATVWidget");
return;
}
addView(v, dividerParams);
}
代码示例来源:origin: stackoverflow.com
int position = getAdapterPosition();
if(v.getId() == expandButton.getId()){
if(mExpandedFoos.get(position)) {
expandableLayout.setVisibility(View.GONE);
代码示例来源:origin: GeoODK/collect
videoParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
} else if (mAudioButton != null && mVideoButton != null) {
audioParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
videoParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
} else {
} else if (mAudioButton == null && mVideoButton != null) {
videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
textParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
} else if (mAudioButton != null && mVideoButton != null) {
audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
代码示例来源:origin: stackoverflow.com
imgparam = new RelativeLayout.LayoutParams(expectedWidth, RelativeLayout.LayoutParams.WRAP_CONTENT);
imgparam.addRule(RelativeLayout.ALIGN_PARENT_TOP, coverImage.getId());
imgparam.addRule(RelativeLayout.CENTER_HORIZONTAL, coverImage.getId());
imgparam.setMargins(10, 20, 10, 0);
coverImage.setLayoutParams(imgparam);
relativeParams.addRule(RelativeLayout.ALIGN_RIGHT, coverImage.getId());
relativeParams.addRule(RelativeLayout.BELOW, coverImage.getId());
relativeParams.setMargins(0, 0, 0, 10);
caption.setId(plastic_iconNum+position);
relativeParams.addRule(RelativeLayout.ALIGN_LEFT, coverImage.getId());
relativeParams.addRule(RelativeLayout.ALIGN_TOP, caption.getId());
relativeParams.setMargins(0, iconMargin, 5, 0);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, coverImage.getId());
layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, coverImage.getId());
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, coverImage.getId());
imgparam.addRule(RelativeLayout.ALIGN_PARENT_TOP, downloadedCover.getId());
imgparam.addRule(RelativeLayout.CENTER_HORIZONTAL, downloadedCover.getId());
imgparam.setMargins(10, 20, 10, 0);
downloadedCover.setLayoutParams(imgparam);
代码示例来源:origin: wuhenzhizao/android-titlebar
centerParams.setMarginStart(PADDING_5);
} else if (leftType == TYPE_LEFT_IMAGEBUTTON) {
centerParams.addRule(RelativeLayout.END_OF, btnLeft.getId());
centerParams.setMarginStart(PADDING_5);
} else if (leftType == TYPE_LEFT_CUSTOM_VIEW) {
centerParams.setMarginEnd(PADDING_5);
} else if (rightType == TYPE_RIGHT_IMAGEBUTTON) {
centerParams.addRule(RelativeLayout.START_OF, btnRight.getId());
centerParams.setMarginEnd(PADDING_5);
} else if (rightType == TYPE_RIGHT_CUSTOM_VIEW) {
代码示例来源:origin: tianzhijiexian/AppBar
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppBar appBar = (AppBar) findViewById(R.id.app_bar);
initAppbar();
appBar.getMenu01(); // 可以通过appbar来获得menu对象
appBar.getTitleView().getId(); // not null
appBar.getNavButton().getId(); // not null
appBar.getLogoView();
appBar.getSubtitleView();
appBar.getCollapseButton();
appBar.canFinishActivity(); // 调用此方法后,点击toolbar左边按钮会让activity finish
// 还有各种toolbar本身的方法……
View customMenu = appBar.getMenu03();
((TextView) customMenu.findViewById(R.id.menu_tv)).setText("kale");
appBar.addMenu(R.drawable.nav_icon_add_red);
appBar.inflateMenu(R.menu.menu_main); // 因为本身就是toolbar,所以仍旧可以装入menu资源
appBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
return id == R.id.action_settings;
}
});
}
内容来源于网络,如有侵权,请联系作者删除!