0

My Android app is targeted to Android 3.1 and has a mode where a different menu is loaded on the action bar, with also a spinner and some buttons. I get the following error:

android.app.ActionBar$LayoutParams cannot be cast to com.android.internal.view.menu.ActionMenuView$LayoutParams
                                                                      at com.android.internal.view.menu.ActionMenuView.onMeasure(ActionMenuView.java:116)

when the menu button is pressed to access certain further options that are not directly displayed on the action bar.

In onPrepareOptionsMenu there are normal instructions to get reference of the items and the spinner is set its LayoutParams. I think this instruction causes the error, doesn't it?

How this error can be solved?

P5music
  • 3,197
  • 2
  • 32
  • 81

1 Answers1

0

[Solved] First I removed a wrong import and explicitly use LinearLayout.LayoutParams but the error just changed to complain about that. I did not understand why the error was issued but I found a solution

not setting the layout params programmatically

but instead in the XML menu file.

P5music
  • 3,197
  • 2
  • 32
  • 81