Best code examples for Android ImageButton class (android.widget.ImageButton)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ImageButton class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android ImageButton examples from Open Source projects
This code example shows how to use the following methods: getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
71:	int nextHeight = Math.max(mNext.getDrawable().getIntrinsicHeight() + mNext.getPaddingTop() 
72:	+ mNext.getPaddingBottom(), 
73:	mNext.getBackground().getMinimumHeight()); 
-
77:	assertEquals("Next incorrect height", nextHeight, mNext.getHeight()); 
-
80:	assertEquals("Next wrong top", (pauseHeight - nextHeight) / 2, mNext.getTop()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setOnClickListener
41:	ImageButton b = new ImageButton( activity ); 
42:	b.setOnClickListener( new MoSyncSendOnClick( handle ) ); 
-
44:	return new ImageButtonWidget( handle, b ); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setOnClickListener, setImageResource
52:	ImageButton button = new ImageButton(this); 
53:	button.setImageResource(getIntent().getIntExtra("moodimg", 0)); 
54:	button.setOnClickListener(this); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setLayoutParams, setOnClickListener, setPadding, setImageResource
31:	b = new ImageButton(context); 
32:	b.setLayoutParams(params); 
33:	b.setOnClickListener(new OnClickListener() { 
-
39:	b.setImageResource(myText); 
-
42:	getTheme().applyNormal1(b); 
-
45:	b.setPadding(p, p, p, p); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
65:	int pauseHeight =  Math.max(mPause.getDrawable().getIntrinsicHeight() 
66:	+ mPause.getPaddingTop() + mPause.getPaddingBottom(), 
67:	mPause.getBackground().getMinimumHeight()); 
-
75:	assertEquals("Pause incorrect height", pauseHeight, mPause.getHeight()); 
-
78:	assertEquals("Pause wrong top", 0, mPause.getTop()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getBackground, setImageResource
181:	final int sliderWidth = mSlider.getBackground().getIntrinsicWidth() - 2 * SHADOW_PADDING; 
-
186:	mSlider.setImageResource(newTab.getActiveIconResource()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBackgroundColor, setOnClickListener, setTag, setImageDrawable
26:	ImageButton imageButton = new ImageButton(this.getContext()); 
27:	imageButton.setTag(item.getKey()); 
-
30:	imageButton.setImageDrawable(drawable); 
31:	imageButton.setBackgroundColor(Color.TRANSPARENT); 
-
34:	imageButton.setOnClickListener(this); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, setOnTouchListener, setColorFilter, setVisibility
166:	RelativeLayout.LayoutParams layout = (LayoutParams) boundaryPoint.getLayoutParams(); 
-
170:	boundaryPoint.setColorFilter(Color.BLACK); 
171:	boundaryPoint.setVisibility(VISIBLE); 
172:	boundaryPoint.setLayoutParams(layout); 
173:	boundaryPoint.setOnTouchListener(onTimelineTouchListener); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLayoutParams
81:	mInitialMargin = ((LinearLayout.LayoutParams)mSlider.getLayoutParams()).leftMargin; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setOnClickListener, setImageResource, setVisibility
88:	action.setImageResource(iconResourceId); 
-
92:	action.setVisibility(onClickListener != null ? View.VISIBLE : View.GONE); 
-
95:	action.setOnClickListener(onClickListener); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getDrawable
73:	ANDROID.assertThat(closeButton).isVisible(); 
74:	StateListDrawable states = (StateListDrawable) closeButton.getDrawable(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setEnabled, setOnClickListener
165:	upButton.setOnClickListener(new View.OnClickListener(){ 
-
184:	upButton.setEnabled(true); 
-
187:	upButton.setEnabled(false); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHitRect, getParent
25:	delegate.getHitRect(delegateArea); 
-
35:	if (View.class.isInstance(delegate.getParent())) { 
36:	((View) delegate.getParent()) 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getContext, setImageDrawable
98:	imageButton.setImageDrawable(imageButton.getContext().getResources().getDrawable(drawableResId)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setLayoutParams, setOnClickListener, setPadding, setImageResource
30:	b = new ImageButton(context); 
31:	b.setLayoutParams(params); 
32:	b.setOnClickListener(new OnClickListener() { 
-
38:	b.setImageResource(myText); 
-
41:	getTheme().applyNormal1(b); 
-
44:	b.setPadding(p, p, p, p); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBackgroundColor, setOnClickListener, setImageResource
82:	final ImageButton iconView = new ImageButton(context); 
83:	iconView.setOnClickListener(new OnClickListener() { 
-
103:	iconView.setImageResource(android.R.drawable.radiobutton_on_background); 
-
105:	iconView.setImageResource(android.R.drawable.radiobutton_off_background); 
-
107:	iconView.setBackgroundColor(Color.TRANSPARENT); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setFocusable, setVisibility
77:	starButton.setVisibility((Util.isOffline(getContext()) || !album.isStarred()) ? View.GONE : View.VISIBLE); 
78:	starButton.setFocusable(false); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setImageDrawable, setVisibility
81:	mImageButton = new ImageButton(context); 
-
144:	mImageButton.setVisibility(VISIBLE); 
145:	mImageButton.setImageDrawable(img); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setEnabled
153:	prevPost.setEnabled(true); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBackgroundResource, setId, setLayoutParams, setOnClickListener
95:	ImageButton button = new ImageButton(getContext()); 
96:	button.setId(id); 
97:	button.setBackgroundResource(drawableId); 
98:	button.setOnClickListener(this); 
-
103:	button.setLayoutParams(params); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setBackgroundColor, setId, setAdjustViewBounds, setImageResource, setScaleType
57:	imageView = new ImageButton(this.context); 
58:	imageView.setId(buttonIds[position]); 
-
60:	imageView.setAdjustViewBounds(true); 
61:	imageView.setBackgroundColor(Color.BLACK); 
62:	imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
-
68:	imageView.setImageResource(cardImages[position]); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getWidth
187:	new Rect(width - mStarButton.getWidth() - mTouchAddition, 0, width, height), 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setOnClickListener, setTag, setImageResource
80:	mHomeBtn.setOnClickListener(this); 
81:	mHomeBtn.setTag(action); 
82:	mHomeBtn.setImageResource(action.getDrawable()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setEnabled
113:	mDelete.setEnabled(enabled); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setOnClickListener
68:	button.setOnClickListener(new View.OnClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getVisibility, setImageDrawable
62:	if (mButton.getVisibility() != View.VISIBLE) { 
-
67:	mButton.setImageDrawable(mCollapsed ? mExpandDrawable : mCollapseDrawable); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setEnabled
24:	public void enableCancel(final boolean enabled) { cancel_.setEnabled(enabled); } 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setOnClickListener, setImageDrawable
60:	this.closeButton = new ImageButton(this.getContext()); 
-
74:	this.closeButton.setImageDrawable(clearIcon); 
75:	this.closeButton.setBackgroundDrawable(null); 
76:	this.closeButton.setOnClickListener(new View.OnClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: requestFocus, setEnabled, setImageResource
264:	mPauseButton.setEnabled(false); 
-
291:	mPauseButton.requestFocus(); 
-
463:	mPauseButton.setImageResource(android.R.drawable.ic_media_pause); 
-
465:	mPauseButton.setImageResource(android.R.drawable.ic_media_play); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setVisibility
279:	mBackButton.setVisibility(View.GONE); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setEnabled, setOnClickListener, setVisibility
290:	mPrevButton.setOnClickListener(mPrevListener); 
291:	mPrevButton.setEnabled(mPrevListener != null); 
-
307:	mPrevButton.setVisibility(View.VISIBLE); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getDrawable, setImageBitmap, setImageURI, setScaleType
227:	bild.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 
228:	bild.setScaleType(ScaleType.CENTER_INSIDE); 
-
241:	bild.setImageURI(Uri.fromFile(file)); 
242:	bild.setScaleType(ScaleType.CENTER_INSIDE); 
-
245:	App.selbst.getProfil().setAvatar(bild.getDrawable()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setClickable, setFocusable, setLayoutParams, setPadding
71:	imageButton = new ImageButton(mContext); 
72:	imageButton.setLayoutParams(new GridView.LayoutParams(150,150)); 
73:	imageButton.setScaleType(ImageButton.ScaleType.CENTER_CROP); 
74:	imageButton.setPadding(7, 8, 7, 8); 
75:	imageButton.setAdjustViewBounds(true); 
-
79:	imageButton.setBackgroundDrawable(d); 
-
86:	imageButton.setImageResource(mThumbIds[position]); 
-
101:	imageButton.setFocusable(false); 
102:	imageButton.setClickable(false); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setOnClickListener, setImageResource
55:	ImageButton button = new ImageButton(this); 
56:	button.setImageResource(getIntent().getIntExtra("extraMsg", 0)); 
57:	button.setOnClickListener(this); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundResource, setScaleType
68:	imageButton = new ImageButton(cont); 
69:	imageButton.setScaleType(ScaleType.FIT_CENTER); 
70:	imageButton.setBackgroundResource(0); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setOnClickListener, setImageDrawable
65:	ImageButton xBtn = new ImageButton(ct); 
-
67:	xBtn.setImageDrawable(clearIcon); 
68:	xBtn.setOnClickListener(listener); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackground, setOnTouchListener
72:	slider = new ImageButton(context); 
-
81:	slider.setBackground(background); 
-
85:	slider.setOnTouchListener(this); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setClickable, setFocusable, setLayoutParams, setPadding
72:	imageButton = new ImageButton(mContext); 
73:	imageButton.setLayoutParams(new GridView.LayoutParams(150,150)); 
74:	imageButton.setScaleType(ImageButton.ScaleType.CENTER_CROP); 
75:	imageButton.setPadding(7, 8, 7, 8); 
76:	imageButton.setAdjustViewBounds(true); 
-
80:	imageButton.setBackgroundDrawable(d); 
-
87:	imageButton.setImageResource(mThumbIds[position]); 
-
102:	imageButton.setFocusable(false); 
103:	imageButton.setClickable(false); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: ofFloat
64:	ObjectAnimator animX = ObjectAnimator.ofFloat(ib, "scaleX", 1.f, 0.f); 
65:	ObjectAnimator animY = ObjectAnimator.ofFloat(ib, "scaleY", 1.f, 0.f); 
-
69:	scalers.addListener(new AnimatorListenerAdapter() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setClickable, setFocusable, setVisibility
84:	inoutimagebutton.setVisibility(8); 
85:	inoutimagebutton.setClickable(false); 
86:	inoutimagebutton.setFocusable(false); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setClickable, setFocusable, setLayoutParams, setPadding
77:	imageButton = new ImageButton(mContext); 
78:	imageButton.setLayoutParams(new GridView.LayoutParams(150,150)); 
79:	imageButton.setScaleType(ImageButton.ScaleType.CENTER_CROP); 
80:	imageButton.setPadding(7, 8, 7, 8); 
81:	imageButton.setAdjustViewBounds(true); 
-
85:	imageButton.setBackgroundDrawable(d); 
-
92:	imageButton.setImageResource(mThumbIds[position]); 
-
107:	imageButton.setFocusable(false); 
108:	imageButton.setClickable(false); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setClickable, setFocusable, setLayoutParams, setPadding
78:	imageButton = new ImageButton(mContext); 
79:	imageButton.setLayoutParams(new GridView.LayoutParams(150,150)); 
80:	imageButton.setScaleType(ImageButton.ScaleType.CENTER_CROP); 
81:	imageButton.setPadding(7, 8, 7, 8); 
82:	imageButton.setAdjustViewBounds(true); 
-
86:	imageButton.setBackgroundDrawable(d); 
-
93:	imageButton.setImageResource(mThumbIds[position]); 
-
108:	imageButton.setFocusable(false); 
109:	imageButton.setClickable(false); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setClickable, setFocusable, setLayoutParams, setPadding
78:	imageButton = new ImageButton(mContext); 
79:	imageButton.setLayoutParams(new GridView.LayoutParams(150,150)); 
80:	imageButton.setScaleType(ImageButton.ScaleType.CENTER_CROP); 
81:	imageButton.setPadding(7, 8, 7, 8); 
82:	imageButton.setAdjustViewBounds(true); 
-
86:	imageButton.setBackgroundDrawable(d); 
-
93:	imageButton.setImageResource(mThumbIds[position]); 
-
108:	imageButton.setFocusable(false); 
109:	imageButton.setClickable(false); 
Full Snippet Info
5
CodeRank
Related Android ImageButton Questions & Answers:
Other Android ImageButton Examples
15:	public class MainActivity extends Activity {
16:	
17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
-
29:	
30:			// flash switch button
31:			btnSwitch = (ImageButton) findViewById(R.id.btnSwitch);
32:	
33:	}

Read More

19:	
20:		private ImageButton btnPlay;
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
-
20:		private ImageButton btnPlay;
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
-
21:		private ImageButton btnForward;
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
-
22:		private ImageButton btnBackward;
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
-
23:		private ImageButton btnNext;
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
-
24:		private ImageButton btnPrevious;
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
-
25:		private ImageButton btnPlaylist;
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
29:		private TextView songTitleLabel;
-
26:		private ImageButton btnRepeat;
27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
29:		private TextView songTitleLabel;
30:		private TextView songCurrentDurationLabel;
-
50:			// All player buttons
51:			btnPlay = (ImageButton) findViewById(R.id.btnPlay);
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
-
51:			btnPlay = (ImageButton) findViewById(R.id.btnPlay);
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
-
52:			btnForward = (ImageButton) findViewById(R.id.btnForward);
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
-
53:			btnBackward = (ImageButton) findViewById(R.id.btnBackward);
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
-
54:			btnNext = (ImageButton) findViewById(R.id.btnNext);
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
-
55:			btnPrevious = (ImageButton) findViewById(R.id.btnPrevious);
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
-
56:			btnPlaylist = (ImageButton) findViewById(R.id.btnPlaylist);
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
60:			songTitleLabel = (TextView) findViewById(R.id.songTitle);
-
57:			btnRepeat = (ImageButton) findViewById(R.id.btnRepeat);
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
60:			songTitleLabel = (TextView) findViewById(R.id.songTitle);
61:			songCurrentDurationLabel = (TextView) findViewById(R.id.songCurrentDurationLabel);

Read More

15:	public class MainActivity extends Activity {
16:	
17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;

Read More

See Code Examples for Android ImageButton Methods: