本文整理匯總了Java中android.support.v7.widget.RecyclerView.getItemAnimator方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getItemAnimator方法的具體用法?Java RecyclerView.getItemAnimator怎麽用?Java RecyclerView.getItemAnimator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getItemAnimator方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof DefaultItemAnimator) {
((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
}
mAdapter = new CancelAdapter(this, new ArrayList<DayLesson>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
mView_FABMenu.setVisibility(View.GONE);
}
示例2: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 實例化控件
final RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
// 設置啟動列表的修改動畫效果(默認為關閉狀態) 23.0.1以後使用方法,23.0.1之前用setSupportsChangeAnimations方法
RecyclerView.ItemAnimator animator = rv.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
// 設置動畫時長
rv.getItemAnimator().setChangeDuration(300);
rv.getItemAnimator().setMoveDuration(300);
// 實現RecyclerView實現豎向列表展示模式
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
rv.setLayoutManager(layoutManager);
// 實例化數據適配器並綁定在控件上
final MainAdapter adapter = new MainAdapter();
rv.setAdapter(adapter);
}
示例3: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof DefaultItemAnimator) {
((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
}
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new SubjectAdapter(this, new ArrayList<Subject>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
FloatingActionButton addSubject = findViewById(R.id.fab_action_1);
addSubject.setVisibility(View.VISIBLE);
addSubject.setLabelText(mContext.getResources().getString(R.string.add_subject));
addSubject.setOnClickListener(this);
}
示例4: changeItemAnimation
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public static void changeItemAnimation(RecyclerView recyclerView, boolean isOpen) {
// 關閉viewholder動畫效果。解決viewholder閃爍問題
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(isOpen);
}
}
示例5: getAnimationDuration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) {
ItemAnimator itemAnimator = recyclerView.getItemAnimator();
return itemAnimator == null ? animationType == 8 ? 200 : 250 : animationType == 8 ? itemAnimator.getMoveDuration() : itemAnimator.getRemoveDuration();
}