title: Calling an Intent dynamically on several buttons
body: <p>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.</p>
  
  <p>What I am currently doing is something like that, on each one of my XML layout, i add two buttons whith onClick property.</p>
  
  <p>For instance on page 5, I have on my previous button:</p>
  
  <pre><code>android:onClick="Page4"
  </code></pre>
  
  <p>and next button </p>
  
  <pre><code>android:onClick="Page6"
  </code></pre>
  
  <p>I also wrote a CustomActivity with these properties:</p>
  
  <pre><code>public void Page4(View v) {
      startActivity(new Intent(this, Page04.class));
      finish();
  }
  public void Page6(View v) {
      startActivity(new Intent(this, Page06.class));
      finish();
  } 
  </code></pre>
  
  <p>This work fine and I wrote a whole application like this, but I really would like to make something more clever.</p>
  
  <p>As you can imagine, when I have something like 100 pages, my code is quite horrible!</p>
  
  <p>I don't know, something like "PreviousPage" or "NextPage"</p>
  
  <pre><code>public void PreviousPage(View v) {
      Intent i= "Generate dynamically an intent for previous page"
      startActivity(i);
      finish();
  } 
  </code></pre>
  
  <p>WHat I was thinking was also giving a parameter in my xml and do something like:</p>
  
  <pre><code>public void GotoPage(View v, int page) {
      startActivity(new Intent(this, Page"+page+".class));
      finish();
  } 
  </code></pre>
  
  <p>I hope you understand what I mean and what I am looking for.</p>