[英]I need that a button dissapears when I logout Facebook Android Studio
I have a problem when I logout using the Facebook API. 使用Facebook API注销时出现问题。 Apart from the button to log in and out, I have another button that allows access to other activity, what happens is that when I logout I want to disappear the button that gives me access to the other activity and I can not do it, I have tried many combinations with all methods of the main activity and nothing works 除了用于登录和注销的按钮外,我还有一个允许访问其他活动的按钮,发生的事情是,当我注销时,我想取消使我能够访问其他活动的按钮,但我无法执行此操作尝试了与主要活动的所有方法进行多种组合的方法,但无济于事
Any suggestions? 有什么建议么?
Get a reference to the Facebook Login Button and set a click listener on it and when click is registered, logout using LoginManager instance and make all your logout procedure ( such as clearing stored access token, clearing cache, etc.) and then make visibility of the other button View.GONE 获取对Facebook登录按钮的引用,并在其上设置一个单击侦听器,并在单击注册后,使用LoginManager实例注销并进行所有注销过程(例如,清除存储的访问令牌,清除缓存等),然后对其他按钮View.GONE
Eg: 例如:
LoginButton mBtnFbLogin = (LoginButton) findViewById(R.id.fb_login_button);
Button otherButton = (Button) findViewById(R.id.other_button)
Now set click listener on it. 现在在其上设置单击侦听器。
mBtnFbLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginManager.getInstance().logOut();
// Make your logout procedure
...
otherButton.setVisibility(View.GONE);
}
});
Thank your for your answer, the solution works. 感谢您的回答,该解决方案有效。 Finally I do this: 最后,我这样做:
@Override
protected void onResume() {
super.onResume();
AppEventsLogger.activateApp(this);
if (AccessToken.getCurrentAccessToken() != null && com.facebook.Profile.getCurrentProfile() != null) {
boton_volver.setVisibility(View.VISIBLE);
boton_volver.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent;
intent = new Intent(v.getContext(), EventosActivity.class);
startActivity(intent);
}
});
} else {
boton_volver.setVisibility(View.INVISIBLE);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.