Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Andreas Robichaux
Andreas Robichaux
2,426 Points

making my own app...how do i load next activity?

I have a basic app I am trying to make that will serve as a portfolio. I have a column of buttons down the middle on my main activity, and I want them to click the button to load the data for the proper sections (copywriting, strategy, etc..)

I got the buttons all made and lined up in there looking pretty and I made a second activity called webActivity. I was going to make one for each section, web, print, copywriting, etc... but remembered I should just make one page template and then code the rest. I honestly just did this in the class but now it seems so much harder to try and do from scratch without his help!

My question is getting the button to load the next activity. my button is called webButton so do i do something like


and honestly thats all i remember :(

1 Answer

Dan Johnson
Dan Johnson
40,532 Points

To wire up an anonymous inner class to launch an activity all you have to do is this:

webButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent(YourCurrentActivity.this, YourTargetActivity.class);
Andreas Robichaux
Andreas Robichaux
2,426 Points

Thank you very much my man, exactly what I was looking for! You guys are the best!