How can i handle array index out of bound?

android, arrays, indexoutofboundsexception

Solution

you are try to get index that not in your array.your `position must be less than array.length`

 if( v == findViewById( R.id.full_image_view ))
              {
                  if(position < imageAdapter.mThumbIds.length){

                    imageView.setImageResource(imageAdapter.mThumbIds[position]);

                 }
               }

Problem

I have a list of image in grid view.When i click the image it shows in full screen mood and with touch change one image to another just increasing position.here is the code for onTouchListener ``` private int position=0; imageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { position++; if( v == findViewById( R.id.full_image_view )) { imageView.setImageResource(imageAdapter.mThumbIds[position]); } } return false; } }); ``` At the last image it it shows error that "it has stopped unexpectedly ".How can i handle the array of index bound?

Original source