public class SettingsActivity extends PreferenceActivity implements OnPreferenceClickListener{
private Preference mLoginPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_layout);
mLoginPreference = getPreferenceManager().findPreference(
getString(R.string.login_pref));
}
@Override
public boolean onPreferenceClick(Preference preference) {
if(preference.getKey().equals(getString(R.string.login_pref))) {
Intent intent = new Intent(SettingsActivity.this, FacebookLoginActivity.class);
startActivity(intent);
return true;
}
return false;
}
}
在 settings_layout.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/white" >
<Preference
android:key="@string/login_pref"
android:title="@string/login_title" />
</PreferenceScreen>
我有一个作为设置屏幕的应用程序,在此Login to your Account
选项中将登录用户的 FB 帐户并更新摘要。这是我编写的代码,但它不起作用,而且我想更新Login to your Account
用户是否使用 Facebook 帐户登录或未登录的摘要。任何帮助,谢谢