本文整理汇总了Java中android.widget.ImageButton.setImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setImageDrawable方法的具体用法?Java ImageButton.setImageDrawable怎么用?Java ImageButton.setImageDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageButton
的用法示例。
在下文中一共展示了ImageButton.setImageDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setNumberKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setNumberKey(ImageButton buttonView, int key) {
Drawable tempDrawable = null;
if (null != mNumForeSelectorArray[key]) {
tempDrawable = mNumForeSelectorArray[key].getConstantState()
.newDrawable();
buttonView.setImageDrawable(tempDrawable);
}
if (null != mNumBgSelectorArray
&& null != mNumBgSelectorArray[key]) {
tempDrawable = mNumBgSelectorArray[key].getConstantState()
.newDrawable();
buttonView.setBackgroundDrawable(tempDrawable);
} else if (null != mNumBgDrawSelector) {
tempDrawable = mNumBgDrawSelector.getConstantState()
.newDrawable();
buttonView.setBackgroundDrawable(tempDrawable);
}
}
示例2: applyTheme
import android.widget.ImageButton; //导入方法依赖的package包/类
public void applyTheme(Theme t) {
Log.d(THIS_FILE, "Theming in progress");
for(int buttonId : DIGITS_BTNS.keySet()) {
ImageButton b = (ImageButton) findViewById(buttonId);
// We need to use state list as reused
t.applyBackgroundStateListDrawable(b, "btn_dial");
// Src of button
Drawable src = t.getDrawableResource("dial_num_"+DIGITS_NAMES.get(buttonId));
if(src != null) {
b.setImageDrawable(src);
}
// Padding of button
t.applyLayoutMargin(b, "dialpad_btn_margin");
}
}
示例3: updateQuickLaunchButtons
import android.widget.ImageButton; //导入方法依赖的package包/类
void updateQuickLaunchButtons() {
final AppManager appManager = (AppManager) GuiceModule.get().getInstance(AppManager.class);
List<App> quickLaunchApps = appManager.getQuickLaunchApps();
for (int i = 0; i < this.buttons.size(); i++) {
ImageButton button = (ImageButton) this.buttons.get(i);
if (i < quickLaunchApps.size()) {
final App app = (App) quickLaunchApps.get(i);
button.setImageDrawable(app.getAppIcon());
button.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
((InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class)).closeDrawer();
appManager.launchAppWithBackButton(app, AppLaunchMethod.Quicklaunch);
}
});
} else {
button.setImageDrawable(null);
button.setOnClickListener(null);
}
}
}
示例4: setOkButton
import android.widget.ImageButton; //导入方法依赖的package包/类
public static void setOkButton(final BaseActivity activity, int resource) {
TextView tvOk = (TextView) activity.findViewById(R.id.tv_right);
ImageButton btnOk = (ImageButton) activity.findViewById(R.id.btn_right);
if (btnOk != null) {
tvOk.setVisibility(View.GONE);
if (resource != 0) {
btnOk.setImageDrawable(activity.getResources().getDrawable(resource));
}
btnOk.setVisibility(View.VISIBLE);
btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.onOkButtonClick();
}
});
}
}
示例5: 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);
}
示例6: setDoneKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDoneKey(ImageButton buttonView) {
if (null != mDoneForeSelector) {
buttonView.setImageDrawable(mDoneForeSelector);
}
if (null != mDoneBgSelector) {
buttonView.setBackgroundDrawable(mDoneBgSelector);
}
}
示例7: setDelKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDelKey(ImageButton buttonView) {
if (null != mDelForeSelector) {
buttonView.setImageDrawable(mDelForeSelector);
}
if (null != mDelBgSelector) {
buttonView.setBackgroundDrawable(mDelBgSelector);
}
}
示例8: setUpButtons
import android.widget.ImageButton; //导入方法依赖的package包/类
/**
* Sets up the overlay buttons
*/
private void setUpButtons() {
// Set up copy buttons
ImageButton firstname = view.findViewById(R.id.copy_firstname);
ImageButton middlename = view.findViewById(R.id.copy_middlename);
ImageButton lastname = view.findViewById(R.id.copy_lastname);
ImageButton username = view.findViewById(R.id.copy_username);
ImageButton email = view.findViewById(R.id.copy_email);
ImageButton password = view.findViewById(R.id.copy_password);
ImageButton date = view.findViewById(R.id.copy_date);
// Set listeners for copy buttons
firstname.setOnClickListener(this);
middlename.setOnClickListener(this);
lastname.setOnClickListener(this);
username.setOnClickListener(this);
email.setOnClickListener(this);
password.setOnClickListener(this);
date.setOnClickListener(this);
// Set listeners for general clicks, dismiss, save, background and card click
view.findViewById(R.id.button_dismiss).setOnClickListener(this);
view.findViewById(R.id.button_save).setOnClickListener(this);
view.findViewById(R.id.background).setOnClickListener(this);
view.findViewById(R.id.card_content).setOnClickListener(this);
// Create copy icon drawable
Drawable copyIcon = getDrawable(R.drawable.icon_copy);
// Set each copy button to use the copy icon
firstname.setImageDrawable(copyIcon);
middlename.setImageDrawable(copyIcon);
lastname.setImageDrawable(copyIcon);
username.setImageDrawable(copyIcon);
email.setImageDrawable(copyIcon);
password.setImageDrawable(copyIcon);
date.setImageDrawable(copyIcon);
}
示例9: 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;
}
示例10: setBookmarked
import android.widget.ImageButton; //导入方法依赖的package包/类
public void setBookmarked(boolean bookmarked) {
MenuItem bookmarkItem = menu.findItem(R.id.cab_bookmark_ayah);
bookmarkItem.setIcon(bookmarked ? R.drawable.ic_favorite : R.drawable.ic_not_favorite);
ImageButton bookmarkButton = (ImageButton) findViewById(R.id.cab_bookmark_ayah);
if (bookmarkButton != null) {
bookmarkButton.setImageDrawable(bookmarkItem.getIcon());
}
}
示例11: instantiateItem
import android.widget.ImageButton; //导入方法依赖的package包/类
public Object instantiateItem(ViewGroup container, int position) {
LayoutInflater inflater = (LayoutInflater) QuickLaunchView.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout pageView = (LinearLayout) inflater.inflate(R.layout.shade_quick_launch_page, null);
for (int i = position * 5; i < (position * 5) + 5; i++) {
ImageButton button = (ImageButton) inflater.inflate(R.layout.quicklaunch_button, null);
button.setScaleType(ScaleType.FIT_CENTER);
if (i < this.quickLaunchApps.size()) {
final App app = (App) this.quickLaunchApps.get(i);
button.setImageDrawable(app.getAppIcon());
button.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
((InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class)).closeDrawer();
LockScreenManager lockScreenManager = (LockScreenManager) GuiceModule.get().getInstance(LockScreenManager.class);
if (lockScreenManager.isPhoneLocked()) {
lockScreenManager.unlockAndLaunchApp(app);
} else {
QuickLaunchView.this.appManager.launchAppWithBackButton(app, AppLaunchMethod.Quicklaunch);
}
}
});
} else {
button.setBackground(null);
button.setOnClickListener(null);
}
pageView.addView(button, new LayoutParams(-1, -1, 0.5f));
}
container.addView(pageView);
return pageView;
}
示例12: setImageButtonEnabled
import android.widget.ImageButton; //导入方法依赖的package包/类
public static void setImageButtonEnabled(Context ctxt, boolean enabled, ImageButton item,
int iconResId) {
item.setEnabled(enabled);
Drawable originalIcon = ctxt.getResources().getDrawable(iconResId);
Drawable icon = enabled ? originalIcon : convertDrawableToGrayScale(originalIcon);
item.setImageDrawable(icon);
}
示例13: playPauseBtnClicked
import android.widget.ImageButton; //导入方法依赖的package包/类
public void playPauseBtnClicked(ImageButton btnPlayPause) {
if (mediaPlayer != null) {
if (mediaPlayer.isPlaying()) {
mediaPlayer.pause();
btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
this,
R.drawable.ic_play_red_48dp));
} else {
mediaPlayer.start();
btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
this,
R.drawable.ic_pause_red_48dp));
}
}
}
示例14: changeIconColor
import android.widget.ImageButton; //导入方法依赖的package包/类
private void changeIconColor(ImageButton imagebutton, String category, boolean isSever)
{
if (imagebutton==null)
return;
String ressourceName=category;
if (isSever)
ressourceName+="_red";
else
ressourceName+="_green";
imagebutton.setImageDrawable(getDrawable(ressourceName));
}
示例15: onSearchViewQueryChange
import android.widget.ImageButton; //导入方法依赖的package包/类
private void onSearchViewQueryChange(final String query, final ImageButton navigateBack,
final TextView results) {
final boolean isDarkThemeSelected = ThemeUtils.isDarkThemeSelected(this);
final Drawable drawable;
if (!TextUtils.isEmpty(query)) {
if (isDarkThemeSelected) {
drawable = getDrawable(R.drawable.ic_clear_white_24dp);
} else {
drawable = getDrawable(R.drawable.ic_clear_black_24dp);
}
} else {
if (results.getVisibility() != View.INVISIBLE) {
results.setVisibility(View.INVISIBLE);
}
if (isDarkThemeSelected) {
drawable = getDrawable(R.drawable.ic_arrow_back_white_24dp);
} else {
drawable = getDrawable(R.drawable.ic_arrow_back_black_24dp);
}
}
if (navigateBack.getDrawable() != drawable) {
navigateBack.setImageDrawable(drawable);
}
if (mSearchResultsCursor != null && !mSearchResultsCursor.isEmpty()) {
resetCardViewBackground(mSearchResultsCursor.getAll(), List.class);
mSearchResultsCursor = null;
}
}