We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Has anyone tried to get Native Android menus from within Processing Android Mode? It would be great to make apps that have the full android look and feel.
I'm not sure which folder the menu.xml file would go but I'm thinking about something like the code below:
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
//need to get menu.xml somehow
void setup()
{
orientation(LANDSCAPE);
}
public class MenuOptionsDemoProject extends Activity
{
/* Called when the activity is first created. /
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);//commented out - not working
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
//MenuInflater inflater = getMenuInflater();//commented out - not working
//inflater.inflate(R.menu.my_menu, menu);//commented out - not working
return true;
}
}
void draw()
{
}
Answers
An example setting an Android widget in processing:
https://forum.processing.org/two/discussion/comment/69600/#Comment_69600
Kf
thanks for the example kfrajer.
Unfortunately my android skills are not good enough to adapt this example to a menu widget, so I've decided to learn Android Studio development in order to understand this, rather than keep asking questions!
So - off topic - Instead of bringing Android to Processing I am going to try and bring processing to Android :)
So far I have imported a processing sketch to Android Studio as a fragment and compiled a working Native Android app. I'm trying to connect a button to a variable in the processing fragment, but I don't know how to get Android to communicate with the variables in the fragment.
@chrios1001===
i think it is the good choice to migrate to AS or Eclipse for android... i dont understand your question about variable; can you post some code with this problem?
You will need to override a listener of your widget. If you post your code, it will help. Also what type of widgets do you see using?
Kf
I'm using the standard processing android example code from here https://github.com/codeanticode/processing-android-tutorials/tree/master/android_studio/ex2_fragmentsv4
I'm Trying to link the variable "ellipseSize" to a button or menu item in MainActivity.java How do we make the variable visible elsewhere in the project?
Sketch.java
I think I have made some progress on this - So I found an example of native menus in processing android here: https://lernprocessing.wordpress.com/2011/03/11/processing-apps-fur-android-optionsmenu/
Which, translated from german and with some tweaks compiles successfully, but there's no way to make the menu appear - this example is from 2011 - maybe android UI has changed too much? Does anyone know how to make the menu appear?
"<_a href="/two/profile/Override">@O_v_e_r_r_i_d_e<_/a>"
should read:
"@O_v_e_r_r_i_d_e"
minus the underscores There is a bug in this forum that replaces the word o-v-e-r-r-i-d-e with links
@chrios1001 You are right about override. the solution is to add a space (' ') between @ and override. You can edit your post and make the change and you will see.
Kf
@chrios1001 I tested this in Android302 and I have to make few changes:
Add the following:
And then these changes in the code, from :
Change to:
Kf
Thanks KF - I can't get this to compile with your additions (Android 3.3.3)
error: The function "setHasOptionsMenu(boolean)" does not exist I have tried to find an example of this function by looking at Android code and copying in, but I have not got it to work yet.
If it was working for you - can you post the full sketch including any additional functions you used?
Here is running code on Android Mode version 3.0.2 (From Add Mode manager)
Kf
I tried using the latest android mode version, 4.0-b7 and I am getting some errors calling any of the Menu calls. I won't be able to go any further today but probably tomorrow...
Kf
Working for me on Android Mode 3.0.2! Thanks Kf - this is awesome. I'm hoping to get a full app bar working one day.