The parameters to Menu.add() have changed in the 1.0 SDK.
http://code.google.com/android/reference/android/view/Menu.html#add(int,
int, int, int)

Note the 3rd parameter is wrong in your source.
R/


On Wed, Nov 26, 2008 at 10:16 PM, Hasan <[EMAIL PROTECTED]> wrote:
>
> Dear friend,
>
> I am hasan from India recently started working on Android. I am
> migrating an Android application originally written for version m5 to
> the latest version of Android. The application has loaded properly,
> but when i click on menu again, i am getting
> "IllegalArgumentException" on the logcat console. Please help me in
> fixing this issue. I am providing the following information that will
> help you to identify the root cause of this problem.
>
> 1. the original piece of code that is throwing this error.
> 2. error output from logcat console
>
> ===============
>
> 1. the original piece of code that is throwing this error.
>
> (I am getting error at the line marked in red. I think all the
> subsequent lines will also throw the same error. )
>
> @Override
>  public boolean onCreateOptionsMenu(Menu menu) {
>      boolean result = super.onCreateOptionsMenu(menu);
>
>      System.out.println("##### Exception thrown here !!!!");
>
>      menu.add(0, VIEW_ROUTE_ID, R.string.menu_view_route,
> R.drawable.icon_route_chevron).setShortcut(
>                '1', 'v');;
>      menu.add(0, VIEW_DETAILS_ID, R.string.menu_view_route_details,
> R.drawable.icon_show_details).setShortcut(
>                '2', 'd');
>      menu.add(0, VIEW_DISTANCE_TO_START_ID,
> R.string.menu_view_distance_to_start,
> R.drawable.icon_start_arrow).setShortcut(
>                '3', 't');
>      menu.add(0, DRIVING_DIRECTIONS_ID, R.string.driving_directions,
> R.drawable.icon_driving_directions).setShortcut(
>                '4', 'r');
>      if (this.listType == LIST_TYPE_MYROUTES) {
>      menu.add(0, GET_FROM_WEB_ID, R.string.get_from_web,
> R.drawable.icon_download).setShortcut(
>                '5', 'w');
>      menu.add(0, EDIT_ROUTE, R.string.edit_route,
> R.drawable.icon_edit_route);
>      menu.add(0, DELETE_ROUTE, R.string.delete_route,
> R.drawable.icon_red_x);
>      }
>      menu.add(0, SETTINGS_ID, R.string.menu_settings,
> R.drawable.icon_settings).setShortcut(
>                '5', 'n');
>      // Get a handle to our submenu so we can add menu items and
> respond to user selections.
>      this.sortOrder = menu.addSubMenu(0, SORT_MENU_ID,
> R.string.menu_sort, R.drawable.icon_sort);
>
>   // we remember the reference to submenu in order to modify it in
> the future
>      this.sortOrder.add(1, SORT_MENU_NAME_ID, 0,getString
> (R.string.menu_sort_name));
>     this.sortOrder.add(1, SORT_MENU_LOCATION_ID,0, getString
> (R.string.label_location));
>     this.sortOrder.add(1, SORT_MENU_DISTANCE_ID,0, getString
> (R.string.menu_sort_distance));
>      this.sortOrder.add(1, VIEW_DISTANCE_TO_START_ID,
> R.drawable.icon_start_arrow, getString
> (R.string.menu_view_distance_to_start));
>
>      return result;
>  }
>
> 2. error output from logcat console
>
> W/dalvikvm(  178): threadid=3: thread exiting with uncaught exception
> (group=0x40010e28)
> E/AndroidRuntime(  178): Uncaught handler: thread main exiting due to
> uncaught exception
> E/AndroidRuntime(  178): java.lang.IllegalArgumentException: order
> does not contain a valid category.
> E/AndroidRuntime(  178): at
> com.android.internal.view.menu.MenuBuilder.getOrdering
> (MenuBuilder.java:657)
> E/AndroidRuntime(  178): at
> com.android.internal.view.menu.MenuBuilder.addInternal
> (MenuBuilder.java:366)
> E/AndroidRuntime(  178): at
> com.android.internal.view.menu.MenuBuilder.add(MenuBuilder.java:394)
> E/AndroidRuntime(  178): at
> com.mapmyfitness.android.MMFMobile.RouteList.onCreateOptionsMenu
> (RouteList.java:936)
> E/AndroidRuntime(  178): at android.app.Activity.onCreatePanelMenu
> (Activity.java:1917)
> E/AndroidRuntime(  178): at
> com.android.internal.policy.impl.PhoneWindow.preparePanel
> (PhoneWindow.java:334)
> E/AndroidRuntime(  178): at
> com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel
> (PhoneWindow.java:565)
> E/AndroidRuntime(  178): at
> com.android.internal.policy.impl.PhoneWindow.onKeyDown
> (PhoneWindow.java:1143)
> E/AndroidRuntime(  178): at
> com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
> (PhoneWindow.java:1533)
> E/AndroidRuntime(  178): at android.view.ViewRoot.deliverKeyEvent
> (ViewRoot.java:1616)
> E/AndroidRuntime(  178): at android.view.ViewRoot.handleMessage
> (ViewRoot.java:1114)
> E/AndroidRuntime(  178): at android.os.Handler.dispatchMessage
> (Handler.java:88)
> E/AndroidRuntime(  178): at android.os.Looper.loop(Looper.java:123)
> E/AndroidRuntime(  178): at android.app.ActivityThread.main
> (ActivityThread.java:3742)
> E/AndroidRuntime(  178): at java.lang.reflect.Method.invokeNative
> (Native Method)
> E/AndroidRuntime(  178): at java.lang.reflect.Method.invoke
> (Method.java:515)
> E/AndroidRuntime(  178): at com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:739)
> E/AndroidRuntime(  178): at com.android.internal.os.ZygoteInit.main
> (ZygoteInit.java:497)
> E/AndroidRuntime(  178): at dalvik.system.NativeStart.main(Native
> Method)
> I/Process (   49): Sending signal. PID: 178 SIG: 3
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to