0

I am new in Android development. I want to ask how can I create an overflow menu with two items. Also, how can I combine it with an option menu I already did, which looks like this:

public class MainActivity extends Activity {


@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater blabla = getMenuInflater();
    blabla.inflate(R.menu.options_menu ,menu);
    return true;


}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()){
        case R.id.OurSponsors:
            Intent i = new Intent("com.--.------.------");
            startActivity(i);
            break;

        case R.id.exit:
            finish();
            break;

    }
    return false;
}

xml

 <item
android:title="Our Sponsors"
android:id="@+id/OurSponsors"
android:icon="@drawable/image"
/>


<item
        android:title="Exit"
        android:id="@+id/exit"
        android:icon="@drawable/exit"
           />

I am a beginner.

4

1 回答 1

0

这是与该http://developer.android.com/guide/topics/resources/menu-resource.html相关的开发人员页面。

您将希望向 XML 布局中的每个菜单项添加android:showAsAction="collapseActionView"(或android:showAsAction="never"取决于您的 API 级别)

于 2013-07-21T14:20:05.100 回答