本文整理匯總了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());
}