本文整理汇总了Java中android.support.v7.widget.DefaultItemAnimator.setSupportsChangeAnimations方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultItemAnimator.setSupportsChangeAnimations方法的具体用法?Java DefaultItemAnimator.setSupportsChangeAnimations怎么用?Java DefaultItemAnimator.setSupportsChangeAnimations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.DefaultItemAnimator
的用法示例。
在下文中一共展示了DefaultItemAnimator.setSupportsChangeAnimations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v7.widget.DefaultItemAnimator; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lifecycle_example);
final LifecycleExampleViewModel viewModel = ViewModelProviders.of(this)
.get(LifecycleExampleViewModel.class);
final Datasource<Person> datasource = viewModel.getDatasource();
final LifecyclePersonAdapter adapter = new LifecyclePersonAdapter(datasource);
final DefaultItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setItemAnimator(itemAnimator);
mRecyclerView.setAdapter(adapter);
mLifecycleComposite = new LifecycleComposite();
mViewHolderTracker = new ViewHolderTracker();
mViewHolderTracker.registerViewHolderObserver(new LifecycleBehavior(mLifecycleComposite));
mViewHolderTracker.setRecyclerView(mRecyclerView);
findViewById(R.id.pause).setOnClickListener(v -> pauseActivity());
}
示例2: setItemAnimatorEnabled
import android.support.v7.widget.DefaultItemAnimator; //导入方法依赖的package包/类
public void setItemAnimatorEnabled(boolean enabled) {
if (enabled) {
DefaultItemAnimator animator = new DefaultItemAnimator();
animator.setSupportsChangeAnimations(false);
setItemAnimator(animator);
} else {
setItemAnimator(null);
}
}