title: Move to next/previous item when click on previous/next button in detailed activity
body: <p>I have a listview data obtained from web-service, when i click on listview item it takes to detailed Activity where description and image are present here when i clcik on nextbutton it should take me to next item in list similarly when click on prebutton it shuld take me to previous item in list, but now i am getting force close when i click on next/pre button, i am using BaseAdapter. following is my code</p>
  
  <p>DetailedActivity</p>
  
  <pre><code>public class SampleDesp extends Activity   {
  
   ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList;
   ListView list;
  
  
      // JSON node keys
      static final String KEY_URL_FOR_MAP = "url_site"; 
      private static final String KEY_TITLE = "title";
      private static final String KEY_SITEURL = "url";
      private static final String KEY_DATE = "date";
      private static final String KEY_NAME = "name";
      private static final String KEY_CONTENT = "content";
      private static final String KEY_URL = "url";
       static final String KEY_SLUG1= "slug";
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
         // requestWindowFeature(Window.FEATURE_NO_TITLE);
          setContentView(R.layout.sampledes);
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
       // move up event handler
          ImageButton preButton = (ImageButton) findViewById(R.id.prevButton);
  
          preButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View view) {
                 movePre();
             }
          });
  
          // move down event handler
          ImageButton nxtButton = (ImageButton) findViewById(R.id.nextButton);
          nxtButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View view) {
                 moveNxt();
             }
          });
  
           ListView list = new ListView(this);
          StationAdapter adapter1 = new StationAdapter(this, songsList);    
           list.setAdapter(adapter1);
  
  
          // getting intent data
          Intent in = getIntent();
          final String url1 = in.getStringExtra(KEY_URL);
  
          ImageView imgv = (ImageView) findViewById(R.id.imgdesc);
          ImageLoader imageLoader = new ImageLoader(getApplicationContext());
          imageLoader.DisplayImage(url1, imgv);
  
  
          // Get JSON values from previous intent
          String songsList1 = in.getStringExtra("song");
          int listPosition = in.getIntExtra("listPosition", 0);
          final String title = in.getStringExtra(KEY_TITLE);
          final String siteurl = in.getStringExtra(KEY_URL_FOR_MAP);
          String date = in.getStringExtra(KEY_DATE);
          String name = in.getStringExtra(KEY_NAME);
          final String content = in.getStringExtra(KEY_CONTENT);
  
          // Displaying all values on the screen
          TextView lblName = (TextView) findViewById(R.id.name_label);
          TextView lblUrl = (TextView) findViewById(R.id.url_label);
  
          TextView lblCost = (TextView) findViewById(R.id.email_label);
          TextView lblDesc = (TextView) findViewById(R.id.mobile_label);
          TextView lblCont = (TextView) findViewById(R.id.content_label);
  
          lblName.setText(title);
          lblUrl.setText(siteurl);
          lblCost.setText(date);
          lblDesc.setText(name);
          lblCont.setText(content);
      }    
  
      private void movePre(){
  
  
  
          list.setSelection(list.getSelectedItemPosition() - 1);
      }
  
  
  
  
          // Move selected item "down" in the ViewList.
          private void moveNxt(){
  
              list.setSelection(list.getSelectedItemPosition() + 1);
  
  
          }
  </code></pre>
  
  <p>StationAdapter</p>
  
  <pre><code>class StationAdapter  extends BaseAdapter{
    private static final String TAG = null;
      private Activity activity;
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
      private static LayoutInflater inflater=null;
      public ImageLoader imageLoader; 
  
      public StationAdapter(Activity a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d) {
          activity = a;
          data=d;
          inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          imageLoader=new ImageLoader(activity.getApplicationContext());
          Log.v(TAG, "Message here");
      }
  
  
  
      public int getCount() {
          return data.size();
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
          View vi=convertView;
          if(convertView==null)
              vi = inflater.inflate(R.layout.myfragment_layout, null);
  
          TextView title = (TextView)vi.findViewById(R.id.name_label); // title
          TextView siteurl = (TextView)vi.findViewById(R.id.url_label);
          TextView date = (TextView)vi.findViewById(R.id.email_label); // artist name
          TextView content = (TextView)vi.findViewById(R.id.content_label);  // duration
          TextView name = (TextView)vi.findViewById(R.id.mobile_label); 
          // duration
          ImageView thumb_image=(ImageView)vi.findViewById(R.id.imgdesc); // thumb image
  
          HashMap&lt;String, String&gt; song = new HashMap&lt;String, String&gt;();
          song = data.get(position);
  
  
          ListView list;
          // Setting all values in listview
         title.setText(song.get(MainActivity.KEY_TITLE));
        // siteurl.setText(song.get(MainActivity.KEY_SITEURL));
          date.setText(song.get(MainActivity.KEY_DATE));
          siteurl.setText(song.get(MainActivity.KEY_URL_FOR_MAP));// correct code
          ((TextView)siteurl).setVisibility(TextView.INVISIBLE);
          content.setText(song.get(MainActivity.KEY_CONTENT));
          name.setText(song.get(MainActivity.KEY_NAME));
          System.out.println("output: " +name);
         imageLoader.DisplayImage(song.get(MainActivity.KEY_URL), thumb_image);
          return vi;
      }
  }
  </code></pre>
  
  <p>LogCat error</p>
  
  <pre><code>02-23 12:32:52.506: E/AndroidRuntime(894): FATAL EXCEPTION: main
  02-23 12:32:52.506: E/AndroidRuntime(894): java.lang.NullPointerException
  02-23 12:32:52.506: E/AndroidRuntime(894):  at com.example.sampleofmain.SampleDesp.moveNxt(SampleDesp.java:137)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at com.example.sampleofmain.SampleDesp.access$1(SampleDesp.java:135)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at com.example.sampleofmain.SampleDesp$2.onClick(SampleDesp.java:82)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.view.View.performClick(View.java:2485)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.view.View$PerformClick.run(View.java:9080)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.os.Handler.handleCallback(Handler.java:587)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.os.Handler.dispatchMessage(Handler.java:92)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.os.Looper.loop(Looper.java:123)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at java.lang.reflect.Method.invokeNative(Native Method)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at java.lang.reflect.Method.invoke(Method.java:507)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  02-23 12:32:52.506: E/AndroidRuntime(894):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>