1

我有

import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;


public class ActivityHome extends SherlockFragmentActivity             {
                super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

  ...........
}

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getSupportMenuInflater();
        inflater.inflate(R.menu.menu_main, menu);
        return true;
    }

但是菜单没有显示在标题栏中,而是显示在屏幕底部(通过单击设备上的“菜单”按钮)。就像正常活动一样......我做错了什么?

菜单xml是:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/menu_add_record"
        android:icon="@drawable/ic_action_plus"
        android:title="@string/add"
        >
    </item>
</menu>

请帮忙!:)

4

1 回答 1

4

ActionBar您可以通过添加android:showAsAction="always"属性来获取单个菜单项以显示在

http://developer.android.com/guide/topics/resources/menu-resource.html

于 2013-09-04T17:31:47.640 回答