我正在玩新的RecyclerView
。并遇到了一些问题:
android:background="?android:attr/selectableItemBackground"
(RecyclerView onItemClick effect in L)如何在点击时使RecyclerView的行为更像ListView,以便用户能够在通知点击监听器之前看到完成点击动画?
我知道我可以通过使用View.postDelayed
来解决此问题,但这似乎不是最佳解决方案,因为在延迟期间,用户可能能够点击更多列表项。
下面是一个android工作室项目存储库的链接,该工作区有ListView
和RecyclerView
并排以帮助演示此问题:https://github.com/ericytsang/question.listview-vs-recyclerview
非常感谢!
答案 0 :(得分:1)
我有同样的问题。我在处理片段并在单击列表项时替换片段,但点击动画未显示。所以,我用代码替换了片段代码来启动另一个Activity,这解决了我的问题。你说在点击监听器转到另一个“活动或某事”之前动画还没有完成,但是对我来说很有效。
这是
的内容NewFragment newFragment = NewFragment.newInstance();
FragmentTransaction ft = (getFragmentManager()).beginTransaction();
ft.replace(R.id.fragment_container, newFragment);
ft.addToBackStack(null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
我用这个
Intent transitionIntent = new Intent(getActivity(), DetailActivity.class);
startActivity(transitionIntent);