我試圖在每個元素上添加一個偵聽器,在其中點擊它的每個元素的列表中打開一個新的活動,並使用該字段給定的參數。 這聽起來很容易,但是當我從listview移動到recyclerview時,我正面臨着一個錯誤運行時錯誤:在繼續之前停止回收視圖
我第一次點擊一個項目,只有第一個,它需要5/6秒才能打開並引發異常以下
的RuntimeException:執行未對保持列表中的活性恢復
活動的停止
這是我使用的設置聽者在viewholder代碼
公共靜態類ViewHolder擴展RecyclerView.ViewHolder實現View.OnClickListener {
private final AdapterRequestListController controller;
// each data item is just a string in this case
public TextView elapsedTime;
public View rootView;
public ViewHolder(View v, AdapterRequestListController controller) {
super(v);
elapsedTime = (TextView) v.findViewById(R.id.rlr_reply_title);
rootView = v;
this.controller = controller;
v.setOnClickListener(this);
}
@Override
public void onClick(View v) {
controller.openReply(getAdapterPosition());
}
}
我看着在控制器的問題(實際上是我的活動),但什麼都沒有改變,AO我搬到了適配器和非常奇怪的是,如果我把聽者在適配器的onbind方法它不會發生
我不喜歡把它放在那裏的原因有很多(噸監聽器更新每次滾動的時間)
任何建議或想法?謝謝!
這是完整的例外
E/ActivityThread: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}
java.lang.RuntimeException: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3465)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3550)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
更新2
這是實際運行的意圖
@Override
public void openReply(int position) {
//TODO
Log.d(TAG, position + " fired");
Intent intent = new Intent(this, ActivityViewReply.class);
Bundle bundle = new Bundle();
bundle.putSerializable(ActivityViewReply.REQUEST_FIELD_NAME, meRequests.get(position));
intent.putExtras(bundle);
startActivity(intent);
}
請顯示您的整個堆棧跟蹤。 – barq
我更新了整個堆棧的問題 –
您是否在該點擊事件上開始了相同的活動? –