Android选项菜单未显示

时间:2015-04-02 11:33:16

标签: android-menu android-optionsmenu

我在选项菜单中有四个选项,并将3个项目作为ifRoom选项,但在屏幕上有空格但只显示两个项目。因此,要真正测试是否没有空间我一如既往地制作了前三个项目,它们表现得很好。有什么想法吗?

enter image description here

这是代码:

package com.techiequickie.bharath.parsetest;

import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;


public class Listbets extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_listbets);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.standard_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.


        switch (item.getItemId()) {
            case R.id.menu_newbet:
                Toast.makeText(Listbets.this, "newbet", Toast.LENGTH_LONG).show();
                return true;
            case R.id.menu_earnings:
                Toast.makeText(Listbets.this, "earnings", Toast.LENGTH_LONG).show();
                return true;
            case R.id.menu_myaccount:
                Toast.makeText(Listbets.this, "myaccount", Toast.LENGTH_LONG).show();
                return true;
            case R.id.menu_viewbets:
                Toast.makeText(Listbets.this, "viewbets", Toast.LENGTH_LONG).show();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }


        //int id = item.getItemId();

        /**noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);*/
    }
}

另一个问题是如何在所有活动中将活动名称更改为我的appname?这段代码在哪里添加?在我的情况下,我的应用程序名称是BOA,但它显示为ListBets,实际上是活动名称。

0 个答案:

没有答案