本文整理汇总了Java中android.support.v4.view.ViewCompat.setActivated方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setActivated方法的具体用法?Java ViewCompat.setActivated怎么用?Java ViewCompat.setActivated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.setActivated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void onBindViewHolder(RecyclerView.ViewHolder vh, int position) {
boolean checked = isItemChecked(position);
if (vh.itemView instanceof Checkable) {
((Checkable) vh.itemView).setChecked(checked);
}
ViewCompat.setActivated(vh.itemView, checked);
}
示例2: getView
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
switch (getItemViewType(position)) {
case 0:
if (convertView == null || convertView.getId() != R.id.list_item) {
convertView = LayoutInflater.from(ActivityChooserView.this.getContext()).inflate(R.layout.abc_activity_chooser_view_list_item, parent, false);
}
PackageManager packageManager = ActivityChooserView.this.getContext().getPackageManager();
ResolveInfo activity = (ResolveInfo) getItem(position);
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(activity.loadIcon(packageManager));
((TextView) convertView.findViewById(R.id.title)).setText(activity.loadLabel(packageManager));
if (this.mShowDefaultActivity && position == 0 && this.mHighlightDefaultActivity) {
ViewCompat.setActivated(convertView, true);
} else {
ViewCompat.setActivated(convertView, false);
}
return convertView;
case 1:
if (convertView == null || convertView.getId() != 1) {
convertView = LayoutInflater.from(ActivityChooserView.this.getContext()).inflate(R.layout.abc_activity_chooser_view_list_item, parent, false);
convertView.setId(1);
((TextView) convertView.findViewById(R.id.title)).setText(ActivityChooserView.this.getContext().getString(R.string.abc_activity_chooser_view_see_all));
}
return convertView;
default:
throw new IllegalArgumentException();
}
}
示例3: toggleActivation
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Perform animation and selection on the current ItemView.
* <br/><br/>
* <b>IMPORTANT NOTE!</b> <i>setActivated</i> changes the selection color of the item
* background if you added<i>android:background="?attr/selectableItemBackground"</i>
* on the row layout AND in the style.xml.
* <br/><br/>
* This must be called after the listener consumed the event in order to add the
* item number in the selection list.<br/>
* Adapter must have a reference to its instance to check selection state.
* <br/><br/>
* If you do this, it's not necessary to invalidate the row (with notifyItemChanged): In this way
* <i>onBindViewHolder</i> is NOT called on selection and custom animations on objects are NOT interrupted,
* so you can SEE the animation in the Item and have the selection smooth with ripple.
*/
private void toggleActivation() {
//itemView.setActivated(mAdapter.isSelected(getAdapterPosition()));
ViewCompat.setActivated(itemView, mAdapter.isSelected(getAdapterPosition()));
if (itemView.isActivated()) {
if (mCheckView != null)
mCheckView.setChecked(true);
} else {
if (mCheckView != null)
mCheckView.setChecked(false);
}
}