小编Kar*_*kar的帖子

如何在Android片段中添加操作栏选项菜单

我想在Android Fragments中有一个选项菜单.ActionBar选项菜单未显示在我的片段中.

这里是我的代码,我有两个onCreateOptionsMenu()onOptionSelected()功能.我的代码没有显示任何错误.但是没有显示选项菜单.

package org.reachout;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import org.general.R;

public class ViewMessageFragment extends Fragment {

    /* (non-Javadoc)
     * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        if (container == null) {
            // We have different layouts, and in one of them this
            // fragment's containing frame doesn't exist.  The fragment
            // may still be created …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-optionsmenu android-actionbar

61
推荐指数
2
解决办法
11万
查看次数