使用RecyclerView时,当我尝试使用makeSceneTransitionAnimation单击并打开一个新活动时,但我无法正常工作。
在使用ListView的情况下,我正在工作。见附件。 请帮助...
代码从这里开始-
RecyclerView recyclerView = (RecyclerView) layoutView.findViewById(R.id.recycler_view_browse);
recyclerView.addOnItemTouchListener(
new RecyclerItemClickListener(getActivity(), recyclerView ,new RecyclerItemClickListener.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override public void onItemClick(View view, int position) {
Log.e("shortlisted","data is here");
((AppController)getActivity().getApplication()).setOthersProfile(albumList.get(position));
// do whatever
ImageView image=new ImageView(view.getContext());
image.setTransitionName("profile");
Intent intent = new Intent(getContext(), BrowseProfile.class);
intent.putExtra("userid",Integer.parseInt(albumList.get(position).getUserID()));
intent.putExtra("alias",albumList.get(position).getAlias());
ActivityOptions options = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), (View)image, "profile");
}
startActivity(intent,options.toBundle());
}
@Override public void onLongItemClick(View view, int position) {
// do whatever
}
})
);
当单击RecyclerView时,将调用此方法。