Hi again,
I have another dumb question (again, I’m not an advanced Android dev).
I have a full screen Processing sketch, and I’m trying to place Android UI on top of it.
Pasting my Activity and Layout code below.
Thanks in advance for any pointers, and tips.
Cheers,
d.
MainActivity.java
package com.example.app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import processing.android.PFragment;
import processing.core.PApplet;
public class MainActivity extends AppCompatActivity {
private PApplet sketch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout frame = new FrameLayout(this);
// frame.setId(CompatUtils.getUniqueViewId());
frame.setId(R.id.test);
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
sketch = new Sketch();
PFragment fragment = new PFragment(sketch);
fragment.setView(frame, this);
}
public void sendMessage(View view) {
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (sketch != null) {
sketch.onRequestPermissionsResult(
requestCode, permissions, grantResults);
}
}
@Override
public void onNewIntent(Intent intent) {
if (sketch != null) {
sketch.onNewIntent(intent);
}
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.example.app.MainActivity" >
<fragment
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@drawable/rounded_button"
android:onClick="sendMessage"
android:text="PLUGGED IN, READY TO GO"
android:textColor="#FFFFFF"
tools:layout_margin="50dp" />
</RelativeLayout>