title: How to implement the prev and next button
body: <p>I want to implement 2 activities , one is a listview with image and text which works well now. The other one is a onClicklistener when I click any ListItem it will start another activity to show more information, with 1 previous button and next button to see the Prev information or next. However there is something wrong with the button. It can only see the previous one and next one once. Which means you can't click the next button twice. Any suggestions will be appreciated  .</p>
  
  <p>Here is my main activity code</p>
  
  <pre><code>package com.example.manchesterunited;
  
  
  import com.example.manchesterunited.R;
  import android.os.Bundle;
  import android.app.AlertDialog;
  import android.app.ListActivity;
  import android.content.Intent;
  
  import android.view.View;
  
  import android.widget.ListView;
  
  import android.widget.Toast;
  
  public class MainActivity extends ListActivity  {
  
  
  static PlayerData data = new PlayerData();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
  CustomAdapter adapter = new CustomAdapter(this);
  
  setListAdapter(adapter);
  
   }
  
  
  
  public void onListItemClick(ListView l,View v, int pos, long id){
      int playerId = (int)id;
      Toast.makeText(getApplicationContext(),"Selected       "+data.getName(pos),Toast.LENGTH_SHORT).show();
  
      Intent intent = new Intent(this, InfoActivity.class);
      intent.putExtra("playerId", playerId);
      startActivity(intent);
  
  }
   }
  </code></pre>
  
  <p>And here is the second activity</p>
  
  <pre><code>package com.example.manchesterunited;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class InfoActivity extends Activity  {
  
  TextView dobText;
  TextView pobText;   
  TextView internationalText;
  Button prevButton;
  Button nextButton;
  PlayerData data = new PlayerData();
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_info);
  
      dobText = (TextView)findViewById(R.id.textView1);
      pobText = (TextView)findViewById(R.id.textView2);
      internationalText = (TextView)findViewById(R.id.textView3);
      prevButton = (Button)findViewById(R.id.prev);
      nextButton =  (Button)findViewById(R.id.next);
      Intent intent = getIntent();
      final int playerId = intent.getExtras().getInt("playerId");  
       dobText.setText("Birthdate:"+String.valueOf(data.getPlayer(playerId).getDob()));
          pobText.setText("Birthplace:"+String.valueOf(data.getPlayer(playerId).getPob()));
          internationalText.setText("International:"+data.getPlayer(playerId).getInternational());
  
  
          prevButton.setOnClickListener(new OnClickListener(){
  
                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
  
                          int newId = playerId-1;
                           dobText.setText("Birthdate:"+String.valueOf(data.getPlayer(newId).getDob()));
                              pobText.setText("Birthplace:"+String.valueOf(data.getPlayer(newId).getPob()));
                              internationalText.setText("International:"+data.getPlayer(newId).getInternational());
  
                      }
  
                  });
  
                  nextButton.setOnClickListener(new OnClickListener(){
  
                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
  
                          int newId = playerId+1;
                           dobText.setText("Birthdate:"+String.valueOf(data.getPlayer(newId).getDob()));
                              pobText.setText("Birthplace:"+String.valueOf(data.getPlayer(newId).getPob()));
                              internationalText.setText("International:"+data.getPlayer(newId).getInternational());
  
                      }
  
                  });}
  
  
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_info, menu);
      return true;
  }
  
  }
  </code></pre>