本文整理汇总了Java中android.widget.ImageView.setImageState方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setImageState方法的具体用法?Java ImageView.setImageState怎么用?Java ImageView.setImageState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setImageState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void onBindView(View view) {
TextView label = (TextView) view.findViewById(R.id.suw_items_title);
label.setText(getTitle());
TextView summaryView = (TextView) view.findViewById(R.id.suw_items_summary);
CharSequence summary = getSummary();
if (summary != null && summary.length() > 0) {
summaryView.setText(summary);
summaryView.setVisibility(View.VISIBLE);
} else {
summaryView.setVisibility(View.GONE);
}
final View iconContainer = view.findViewById(R.id.suw_items_icon_container);
final Drawable icon = getIcon();
if (icon != null) {
final ImageView iconView = (ImageView) view.findViewById(R.id.suw_items_icon);
// Set the image drawable to null before setting the state and level to avoid affecting
// any recycled drawable in the ImageView
iconView.setImageDrawable(null);
iconView.setImageState(icon.getState(), false /* merge */);
iconView.setImageLevel(icon.getLevel());
iconView.setImageDrawable(icon);
iconContainer.setVisibility(View.VISIBLE);
} else {
iconContainer.setVisibility(View.GONE);
}
view.setId(getViewId());
}