Android点击切换控件显示隐藏 EventBas切换

button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        if(p){
            p=false;
            Log.i("TS",!p+""); Event event = new Event(p);

            EventBus.getDefault().post(event );
        }
        else if(p==false){
            p=true;
            Event event = new Event(p);
            EventBus.getDefault().post(event);
            Log.i("TS",!p+"SSSS");
        }
    }
});

 

@Subscribe(threadMode = ThreadMode.POSTING)
public void getEvent(Event event){
    boolean b = event.getB();
    Log.i("TS",!b+"AAA");
    if(b){
        mVp.setVisibility(View.VISIBLE);
        imageView.setVisibility(View.VISIBLE);
        smartRefreshLayout.setVisibility(View.GONE);
    }else {
        mVp.setVisibility(View.GONE);
        imageView.setVisibility(View.GONE);
        smartRefreshLayout.setVisibility(View.VISIBLE);
    }
}

你可能感兴趣的:(Android点击切换控件显示隐藏 EventBas切换)