本文整理了Java中android.widget.ImageButton.getContext()
方法的一些代码示例,展示了ImageButton.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.getContext()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:getContext
暂无
代码示例来源:origin: ankidroid/Anki-Android
private void setDeckExpander(ImageButton expander, ImageButton indent, Sched.DeckDueTreeNode node){
boolean collapsed = mCol.getDecks().get(node.did).optBoolean("collapsed", false);
// Apply the correct expand/collapse drawable
if (collapsed) {
expander.setImageDrawable(mExpandImage);
expander.setContentDescription(expander.getContext().getString(R.string.expand));
} else if (node.children.size() > 0) {
expander.setImageDrawable(mCollapseImage);
expander.setContentDescription(expander.getContext().getString(R.string.collapse));
} else {
expander.setImageDrawable(mNoExpander);
}
// Add some indenting for each nested level
int width = (int) indent.getResources().getDimension(R.dimen.keyline_1) * node.depth;
indent.setMinimumWidth(width);
}
代码示例来源:origin: cbeyls/fosdem-companion-android
@Override
public void onChanged(BookmarkStatus bookmarkStatus) {
if (bookmarkStatus == null) {
imageButton.setEnabled(false);
imageButton.setImageResource(R.drawable.ic_bookmark_outline_white_24dp);
} else {
// Only animate updates, when the button was already enabled
final boolean animate = bookmarkStatus.isUpdate() && imageButton.isEnabled();
imageButton.setEnabled(true);
if (bookmarkStatus.isBookmarked()) {
imageButton.setContentDescription(imageButton.getContext().getString(R.string.remove_bookmark));
imageButton.setImageResource(animate ? R.drawable.avd_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
} else {
imageButton.setContentDescription(imageButton.getContext().getString(R.string.add_bookmark));
imageButton.setImageResource(animate ? R.drawable.avd_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
}
final Drawable drawable = imageButton.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
}
});
代码示例来源:origin: wasdennnoch/AndroidN-ify
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
ImageButton action = (ImageButton) liparam.view;
Context context = action.getContext();
ResourceUtils res = ResourceUtils.getInstance(context);
int width_height = res.getDimensionPixelSize(R.dimen.notification_media_action_width);
int padding = ResourceUtils.getInstance(context).getDimensionPixelSize(R.dimen.notification_media_action_padding);
LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(width_height, width_height);
lParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.notification_media_action_margin));
lParams.setMargins(0, 0, res.getDimensionPixelSize(R.dimen.notification_media_action_margin), 0);
action.setLayoutParams(lParams);
action.setPadding(padding, padding, padding, padding);
action.setBackground(res.getDrawable(R.drawable.notification_material_media_action_background));
}
});
内容来源于网络,如有侵权,请联系作者删除!