In order that my connection to ioio will not die upon the phone screen shutting 
down, I put most of the ioio activity into a separate class.
I have a text view and a button defined on the main activity.

I defined a constructor in IoioTerbiumActivity which takes as an input the 
MainActivity object. That way I can control the text view and button from 
inside IoioTerbiumActivity.

When I tried the project, it showed the text view and the button but clearly 
did not start my ioio class.
It clearly doesn't make sense to create the class and then call startActivity 
with a new intent. If I just call startActivity, how do I bring across the 
parent class?
If I use the my1 from the constructor, what is the proper way to start the 
activity?

public class MainActivity extends AppCompatActivity {
   TextView timerView;
   int runState = 0;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      timerView = (TextView) findViewById(R.id.timerView);
      Button b = (Button) findViewById(R.id.startBut);
      b.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            String txtTmp = getString(R.string.start_lab);
            Button b = (Button) v;
            switch (runState) {
               case 0:
               case 1:
                  txtTmp = getString(R.string.stop_lab);
                  runState++;
                  break;

               case 2:
                  runState++;
                  break;

               default:
                  runState = 0;
                  break;
            }
            b.setText(txtTmp);
         }
      });
//    IoioTerbiumActivity my1 = new IoioTerbiumActivity(this);
//    startActivity(new Intent(this,IoioTerbiumActivity.class));
   }
}

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to