我有一个RecyclerView适配器,有意向下一个Activity
转换退出代码:
public ViewHolderEvents onCreateViewHolder(ViewGroup viewGroup, int i) {
if(Build.VERSION.SDK_INT>=21) {
((Activity) context).getWindow().setSharedElementExitTransition(TransitionInflater.from(context).inflateTransition(R.transition.shared_element_transition));
}
View view=layoutInflater.inflate(R.layout.custom_event_row, viewGroup, false);
ViewHolderEvents viewHolder =new ViewHolderEvents(view);
return viewHolder;
}`
调用下一个活动:
if(Build.VERSION.SDK_INT>=21) {
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, view.findViewById(R.id.imageView), view.findViewById(R.id.imageView).getTransitionName());
ActivityCompat.startActivity((Activity)context, intent, optionsCompat.toBundle());
}
else
{context.startActivity(intent);}
首次进入应用程序时按卡片似乎没有问题。但是,如果我使用搜索(这是另一个活动),然后回到主要活动,然后点击任何卡,应用程序崩溃
logcat的:
Process: com.squaredbytes.eventlane, PID: 23576
java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1544)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.ActivityManagerProxy.isTopOfTask(ActivityManagerNative.java:4504)
at android.app.Activity.isTopOfTask(Activity.java:5381)
at android.app.Activity.startActivityForResult(Activity.java:3780)
at android.app.Activity.startActivity(Activity.java:4023)
at android.support.v4.app.ActivityCompatJB.startActivity(ActivityCompatJB.java:26)
at android.support.v4.app.ActivityCompat.startActivity(ActivityCompat.java:98)
at app.EventAdapter$ViewHolderEvents$1.onClick(EventAdapter.java:142)
at android.view.View.performClick(View.java:4761)
at android.view.View$PerformClick.run(View.java:19767)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
先谢谢。