如何在抽屉按钮后制作选项菜单?

时间:2018-02-22 15:37:11

标签: java android xml options-menu

我想要一个抽屉切换按钮后的选项菜单,如this app。我想要左边的选项菜单,写双方(不要妥协任何)。谁能告诉我怎么做?

enter image description here

- :我的工具栏: -

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
   getMenuInflater().inflate(R.menu.option_menu, menu);
}

- :我的选项菜单: -

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/0"
        android:icon="@drawable/ic_0"
        android:title=""
        app:showAsAction="always"
        android:orderInCategory="0"/>

    <item
        android:icon="@drawable/ic_1"
        android:orderInCategory="1"
        android:title=""
        app:showAsAction="always">
        <menu>
            <item
                android:id="@+id/2"
                android:icon="@drawable/ic_2"
                android:orderInCategory="2"
                android:title="2" />

            <item
                android:id="@+id/3"
                android:icon="@drawable/ic_3"
                android:orderInCategory="3"
                android:title="3" />

            <item
                android:id="@+id/4"
                android:icon="@drawable/ic_4"
                android:orderInCategory="4"
                android:title="4" />

            <item
                android:id="@+id/5"
                android:icon="@drawable/ic_5"
                android:orderInCategory="5"
                android:title="5" />

            <item
                android:id="@+id/6"
                android:icon="@drawable/ic_6"
                android:orderInCategory="6"
                android:title="6" />
        </menu>
    </item>
</menu>

- :在xml中: -

prodord = db.Table('prodord',
    db.Column('prod_id', db.Integer, db.ForeignKey('Product.id'), primary_key=True),
    db.Column('order_id', db.Integer, db.ForeignKey('AOrder.id'), primary_key=True),
    db.Column('quantity', db.Integer)
)


class Product(db.Model):
    __tablename__ = 'Product'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)


class User(db.Model):
    __tablename__ = 'User'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)


class AOrder(db.Model):
    __tablename__ = 'AOrder'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('User.id'))
    timedate = db.Column(db.String)
    products = db.relationship('Product', secondary=prodord, lazy='subquery',
        backref=db.backref('orders', lazy=True))

0 个答案:

没有答案