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