Showing Visualizations in Particular Positions in Android Studio

edited March 2018 in Android Mode

I am developing an Application in Android. For the visualization part, I am using Processing. Now I would like to show a number of visualization on one Android Activity.

The standard code for one visualization is the following:

public class MainActivity extends AppCompatActivity {
  private PApplet sketch;

  protected void onCreate(Bundle savedInstanceState) {
    FrameLayout frame = new FrameLayout(this);
    setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

    sketch = new Sketch();
    PFragment fragment = new PFragment(sketch);
    fragment.setView(frame, this);

The code found on the "Processing for Android" website works for a single visualization. Now I would like to extend this to a number of visualizations each given a specific (x,y) position on the Activity Layout. Which methods allow me to do that?

Can you point me in the right direction?

Kind regards,



  • edited March 2018 Answer ✓

    I have found an answer to my questions.. Answer lie in setting a Static ID to my FrameLayouts and then losing the "SetContentView()" method..

    public class MainActivity extends AppCompatActivity {
        private PApplet sketch1;
        protected void onCreate(Bundle savedInstanceState) {
            FrameLayout frame1 = new FrameLayout(this);
            sketch1 = new sketchone();
            PFragment fragment1 = new PFragment(sketch1);
            fragment1.setView(frame1, this);
  • @nvwingh===

    sorry, i dont understand what you are doing: more precisely what are you calling "visualizations"??? - And why setting static the id permits more than one "visualization"???

  • With visualizations I mean to communicate information clearly and efficiently via statistical graphics, plots and information graphics. So using obtained data in Graphs, BoxPlots,..

    The idea is to have a number of FrameLayouts in different positions on the screen. So to define a number of FrameLayouts with different relative screen positions. Setting the id dynamically does not allow me control on the position of the FrameLayouts. Setting it statically does..

    Sorry for the long wait, I was working on something else..

  • Beste Niels, Ik heb al een tijdje gewerkt nu met P5 en wil nu verder leren op AS Het zijn mijn eerste stappen in deze wereld. Ik zou je willen vragen of je een voorbeeld programma, anders dan die van op de Github, om mee te beginnen. Zit je ook op het niewe forum?

Sign In or Register to comment.