Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:26:04+00:00 2026-05-21T11:26:04+00:00

I currently have an application that look like a book: several pages, and 2

  • 0

I currently have an application that look like a book: several pages, and 2 buttons at the bottom linking to next page and previous page.

What I am currently doing is something like that, on each one of my XML layout, i add two buttons whith onClick property.

For instance on page 5, I have on my previous button:

android:onClick="Page4"

and next button

android:onClick="Page6"

I also wrote a CustomActivity with these properties:

public void Page4(View v) {
    startActivity(new Intent(this, Page04.class));
    finish();
}
public void Page6(View v) {
    startActivity(new Intent(this, Page06.class));
    finish();
} 

This work fine and I wrote a whole application like this, but I really would like to make something more clever.

As you can imagine, when I have something like 100 pages, my code is quite horrible!

I don’t know, something like “PreviousPage” or “NextPage”

public void PreviousPage(View v) {
    Intent i= "Generate dynamically an intent for previous page"
    startActivity(i);
    finish();
} 

WHat I was thinking was also giving a parameter in my xml and do something like:

public void GotoPage(View v, int page) {
    startActivity(new Intent(this, Page"+page+".class));
    finish();
} 

I hope you understand what I mean and what I am looking for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:26:04+00:00Added an answer on May 21, 2026 at 11:26 am

    Create a java.util.List or java.Util.Map containing your Activities.

    List activities = new ArrayList();
    activities.add(Activity1.class);
    activities.add(Activity2.class);
    activities.add(Activity3.class);
    

    Start your activity by calling

    startActivity(new Intent(this,activities.get(i));
    

    If you need to be able to seach by key, you can do the same with a map,

    Map activities = new HashMap();
    activities.add("activity1",Activity1.class);
    activities.add("activity2",Activity2.class);
    activities.add("activity3",Activity3.class);
    

    Start your activity by calling

    startActivity(new Intent(this,activities.get("activity1"));
    

    By storing it in a List/Map, it should be fairly easy to implement first,previous,next,last functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an application that uses a browserfield to access an internet page
I currently have a UINavigationController based application that works just fine. I'd like to
I have an MVC 2 application that every page requires authorization on (except currently
Sometimes my application generates URLs that look like http://localhost/?Area= or http://localhost/SomeController?Area= I don't currently
I currently have a web application that I would like to scale out using
We currently have an application that depends largely on stored procedures. There is a
Currently I have an application that connects to a Terminal Server over TCP/IP using
I currently have a mobile application that can record speech as either a WAV
We have a web application that uses dropbox as file storage. We have currently
I am working on splitting out an existing, working application that I currently have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.