我是Android的新手,正在使用app.help我。我的日志就在这里
Could not dispatch event: class com.shalom.shalombase.event.RequestPurchaseEvent to handler [EventHandler public void com.shalom.shalombase.activity.MainActivity.onRequestPurchaseEvent(com.shalom.shalombase.event.RequestPurchaseEvent)]: null
at com.squareup.otto.Bus.throwRuntimeException(Bus.java:456)
at com.squareup.otto.Bus.dispatch(Bus.java:386)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367)
at com.squareup.otto.Bus.post(Bus.java:336)
将事件发布到主要活动的Myfragment subcriptionfragment。
public class SubscribeFragment extends ShalomBaseFragment {
private Button subscribeLayout;
private LinearLayout subscribebuttonslayout;
private FrameLayout sampleframe;
private RelativeLayout subscribelayout;
View progressLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.subscribe_layout, container, false);
}
@Subscribe
public void onStoreProgressEvent (StoreProgressEvent event) {
if(event!=null&&progressLayout!=null)
{
if(event.isInProgress)
progressLayout.setVisibility(View.VISIBLE);
else
progressLayout.setVisibility(View.GONE);
}
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initialize(view);
subscribebuttonslayout.setVisibility(View.VISIBLE);
subscribelayout.setVisibility(View.VISIBLE);
subscribeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bus.post(new RequestPurchaseEvent(BaseConstants.YEARLY_SUBSCRIPTION));
}
});
getChildFragmentManager().beginTransaction()
.replace(R.id.sample_frame, new LibrarySamleIssueFragment())
.commit();
}
private void initialize(View view) {
subscribeLayout = (Button) view.findViewById(R.id.button1);
subscribebuttonslayout = (LinearLayout) view.findViewById(R.id.subscribe_buttons_layout);
sampleframe = (FrameLayout) view.findViewById(R.id.sample_frame);
progressLayout = (View) view.findViewById(R.id.progress_layout);
subscribelayout = (RelativeLayout) view.findViewById(R.id.subscribe_layout);
}
}
请帮助我。它在S3上工作正常,但它在Nexus7上造成了问题。 我不知道代码有什么问题。我对此感到困惑
答案 0 :(得分:2)
otto代码:
administrator/method/function
接下来的操作是:
method.invoke(target, event);
你的方法抛出由otto
捕获的异常所以,这是我的条件。