1

我使用 FragmentDialog 订阅使用 otto 库的事件。

  @Subscribe
    public void onPickupRequestResponse (PassengerPickupRequestResponseEvent event){
        Toast.makeText(this.getActivity().getApplicationContext(), "Event handled", Toast.LENGTH_SHORT).show();
        dismiss();
    }

我在 OnResume 事件中注册 FragmentDialog 并在 onPause 方法中取消注册。

 @Override
    public void onResume() {
        super.onResume();
        App.bus.register(this); 
    }

    @Override
    public void onPause() {
        super.onPause();
        App.bus.unregister(this);         
    }

然后在活动中我发布活动

 App.bus.post(new PassengerPickupRequestResponseEvent());

但我的 FragmentDialog 不处理此事件。

4

1 回答 1

0

而不是onResumeandonPause您可以覆盖dismiss()to unregister and 在onCreateDialog方法中您可以注册总线。然后你应该能够与总线交互。

于 2014-04-03T18:10:41.867 回答