我对android和facebook插件很新。按照facebook中提到的步骤进行操作
开发者网站。
https://developers.facebook.com/docs/android/scrumptious/authenticate/
转到第3步。
I followed it without missing any steps.
However, I do not see a menu at the bottom when i am logged in.Any help?
Below is the snippet of important codes and xml.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// only add the menu when the selection fragment is showing
if (fragments[SELECTION].isVisible()) {
if (menu.size() == 0) {
Log.d("onPrepareOptionsMenu","Yes");
settings = menu.add(R.string.settings);
}
return true;
} else {
menu.clear();
settings = null;
}
return false;
}
遵循main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment android:name="com.punit.xxx.SelectionFragment"
android:id="@+id/selectionFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment android:name="com.punit.xxx.SplashFragment"
android:id="@+id/splashFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment android:name="com.facebook.widget.UserSettingsFragment"
android:id="@+id/userSettingsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
我试着写一些日志,发现OnPrepareotionsMenu从未被调用过。
答案 0 :(得分:0)
*item android:id="@+id/action_logout" MyNews:showAsAction="never" android:actionProviderClass="android.support.v7.widget.ShareActionProvider" android:orderInCategory="10" android:title="@string/logout"/*
注意:将*替换为&lt;或&gt;。
添加
@Override public boolean onOptionsItemSelected(MenuItem item) {switch(item.getItemId()){ case R.id.action_logout: showSettingsFragment(); return true; } return false;
} public void showSettingsFragment(){ showFragment(SETTINGS, true); }
它对我有用。