Processing Sketch + Options Menu
in
Android Processing
•
1 year ago
Heya,
I am trying to add an options menu to my processing sketch activity. Trying to create the menu by inflating a menu resource like this:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game, menu);
return true;
}
Ends in "R does not have a field menu" , which is bullshit. I do have a plain menu.xml file, and it is also referenced in the generated R.java file.
Okay, so I thought maybe I can create the menu by code instead of using an xml. That works to some extent, I can create a menu with default text buttons using this method:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, Menu.NONE, "Play");
menu.add(1, 2, Menu.NONE, "Pause");
menu.add(2, 3, Menu.NONE, "Options");
return super.onCreateOptionsMenu(menu);
}
Cool, but: I cannot set Icons like that, so I am stuck with the default ugly text button style. When I try to reference my menu items in a variable and use "setIcon(..)" I again have to give it an icon resource, which it does not find (R has no field blabla...).
Very annoying. Any ideas why it tells me R does not have the fields although it has?
EDIT: When I use the code in a normal "Activity"-class, it works. When I use it inside a "PApplet"-class (having added the processing-core.jar to the build path of the project), it no longer finds any resources of the project from inside the class...
Any ideas how to tackle this?
Cheers
I am trying to add an options menu to my processing sketch activity. Trying to create the menu by inflating a menu resource like this:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game, menu);
return true;
}
Ends in "R does not have a field menu" , which is bullshit. I do have a plain menu.xml file, and it is also referenced in the generated R.java file.
Okay, so I thought maybe I can create the menu by code instead of using an xml. That works to some extent, I can create a menu with default text buttons using this method:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, Menu.NONE, "Play");
menu.add(1, 2, Menu.NONE, "Pause");
menu.add(2, 3, Menu.NONE, "Options");
return super.onCreateOptionsMenu(menu);
}
Cool, but: I cannot set Icons like that, so I am stuck with the default ugly text button style. When I try to reference my menu items in a variable and use "setIcon(..)" I again have to give it an icon resource, which it does not find (R has no field blabla...).
Very annoying. Any ideas why it tells me R does not have the fields although it has?
EDIT: When I use the code in a normal "Activity"-class, it works. When I use it inside a "PApplet"-class (having added the processing-core.jar to the build path of the project), it no longer finds any resources of the project from inside the class...
Any ideas how to tackle this?
Cheers
2