How to Switch to Another Activity

First, create a new activity by:

  1. creating a new Java class that extends Activity (for our example, we’ll call it Step1Activity)
  2. creating a new XML layout
  3. adding the new activity to the Android manifest XML

Second, from, say, a button’s onClick() implementation, add this:

Intent i = new Intent(getApplicationContext(), Step1Activity.class);

To resolve various names, you’ll need to import a bunch of things. For example, to resolve ‘Intent’, you’ll need this:

import android.content.Intent;

In general, I Google the name (along with “android”) and use the URL at to tell me what the import is.

Published in: on January 18, 2012 at 4:49 pm  Leave a Comment  

The URI to TrackBack this entry is:

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: