當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewCompat.setActivated方法代碼示例

本文整理匯總了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);
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:8,代碼來源:ItemChoiceManager.java

示例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();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:28,代碼來源:ActivityChooserView.java

示例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);
    }
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:27,代碼來源:AnimeRecyclerAdapter.java


注:本文中的android.support.v4.view.ViewCompat.setActivated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。