Submenu within menu within menu ?

Posted by abhishek mishra on Stack Overflow See other posts from Stack Overflow or by abhishek mishra
Published on 2010-06-07T12:37:44Z Indexed on 2010/06/07 12:42 UTC
Read the original article Hit count: 421

Filed under:

On pressing menu button , I have 2 options : Add & more. On click of more i have 3 options : Organize ,Export & Exit On click of Organize i want other 5 options.

On click of more i get my submenu. But i want other 5 options on click of organize.How do i proceed???

My code in parts is as follows : XML file-------------------------------

 <item    
    android:id="@+id/more"    
    android:title="@string/moreMenu"    
    android:icon="@drawable/icon">
    <menu>
        <item android:id="@+id/Organize"
        android:title="@string/Organize" />

        <item android:id="@+id/Export"
        android:title="@string/Export" />
    </menu>  
    </item> 

android:id="@+id/add"
android:title="@string/addMenu"
android:icon="@drawable/add"/>

Java------------------------- package com.tcs.QuickNotes;

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

public class ToDoList extends Activity { Menu menu; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.todolist);

}

public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.layout.categorymenu, menu);

     return true; 


 }  

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

     case R.id.more:   
           Toast.makeText(this, "You pressed more!", Toast.LENGTH_LONG).show();

//(What needs to be done from here) return true;

     case R.id.add:
       Toast.makeText(this, "You pressed add!", Toast.LENGTH_LONG).show();
      return true;
       }
     return false;
     }

public boolean onPrepareOptionsMenu(Menu menu) {
return true;
}

}

© Stack Overflow or respective owner

Related posts about android