title: How to display image on full screen on click android?
body: <p>I am a newbie in android programming and I created a image gallery app to display images on SD card in grid view . It's working fine but I want to select any image and display it on full screen in another activity. I guess its easier when using a String array but I am using an array list to hold/store images. So I don't know how to display images on full screen using that. Can anyone help me out?</p>
  
  <p><strong>ImageGallery.java</strong></p>
  
  <pre><code>public class ImageGallery extends AppCompatActivity {
      public static ArrayList&lt;Model_images&gt; al_images = new ArrayList&lt;&gt;();
      boolean boolean_folder;
      Adapter_PhotosFolder obj_adapter;
      GridView gv_folder;
      private static final int REQUEST_PERMISSIONS = 100;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_image_gallery);
          gv_folder = (GridView)findViewById(R.id.gv_folder);
  
          gv_folder.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                  Intent intent = new Intent(getApplicationContext(), PhotosActivity.class);
                  intent.putExtra("value",i);
                  startActivity(intent);
              }
          });
   public ArrayList&lt;Model_images&gt; fn_imagespath() {
          al_images.clear();
  
          int int_position = 0;
          Uri uri;
          Cursor cursor;
          int column_index_data, column_index_folder_name;
  
          String absolutePathOfImage;
          uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
  
          String[] projection = {MediaStore.MediaColumns.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
  
          final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
          cursor = getApplicationContext().getContentResolver().query(uri, projection, null, null, orderBy + " DESC");
  
          column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
          column_index_folder_name = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
          while (cursor.moveToNext()) {
              absolutePathOfImage = cursor.getString(column_index_data);
              Log.e("Column", absolutePathOfImage);
              Log.e("Folder", cursor.getString(column_index_folder_name));
  
              for (int i = 0; i &lt; al_images.size(); i++) {
                  if (al_images.get(i).getStr_folder().equals(cursor.getString(column_index_folder_name))) {
                      boolean_folder = true;
                      int_position = i;
                      break;
                  } else {
                      boolean_folder = false;
                  }
              }
  
  
              if (boolean_folder) {
  
                  ArrayList&lt;String&gt; al_path = new ArrayList&lt;&gt;();
                  al_path.addAll(al_images.get(int_position).getAl_imagepath());
                  al_path.add(absolutePathOfImage);
                  al_images.get(int_position).setAl_imagepath(al_path);
  
              } else {
                  ArrayList&lt;String&gt; al_path = new ArrayList&lt;&gt;();
                  al_path.add(absolutePathOfImage);
                  Model_images obj_model = new Model_images();
                  obj_model.setStr_folder(cursor.getString(column_index_folder_name));
                  obj_model.setAl_imagepath(al_path);
  
                  al_images.add(obj_model);
  
  
              }
  
  
          }
  
  
          for (int i = 0; i &lt; al_images.size(); i++) {
              Log.e("FOLDER", al_images.get(i).getStr_folder());
              for (int j = 0; j &lt; al_images.get(i).getAl_imagepath().size(); j++) {
                  Log.e("FILE", al_images.get(i).getAl_imagepath().get(j));
              }
          }
          obj_adapter = new Adapter_PhotosFolder(getApplicationContext(),al_images);
          gv_folder.setAdapter(obj_adapter);
          return al_images;
      }
  </code></pre>
  
  <p><strong>PhotosActivity.java</strong></p>
  
  <pre><code>public class PhotosActivity extends AppCompatActivity {
      int int_position;
      private GridView gridView;
      GridViewAdapter adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_image_gallery);
          gridView = (GridView)findViewById(R.id.gv_folder);
          int_position = getIntent().getIntExtra("value", 0);
          adapter = new GridViewAdapter(this, al_images,int_position);
          gridView.setAdapter(adapter);
          final ImageView imageView = (ImageView) findViewById(R.id.iv_image);
  
          gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
                  Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
                  i.putExtra("id", position);
                  startActivity(i);
              }
          });
  
  
      }
  </code></pre>
  
  <p><strong>GridViewAdapter.java</strong></p>
  
  <pre><code>public class GridViewAdapter extends ArrayAdapter&lt;Model_images&gt; {
  
      Context context;
      ViewHolder viewHolder;
      ArrayList&lt;Model_images&gt; al_menu = new ArrayList&lt;&gt;();
      int int_position;
  
  
      public GridViewAdapter(Context context, ArrayList&lt;Model_images&gt; al_menu,int int_position) {
          super(context, R.layout.activity_adapter__photos_folder, al_menu);
          this.al_menu = al_menu;
          this.context = context;
          this.int_position = int_position;
  
  
      }
  
      @Override
      public int getCount() {
  
          Log.e("ADAPTER LIST SIZE", al_menu.get(int_position).getAl_imagepath().size() + "");
          return al_menu.get(int_position).getAl_imagepath().size();
      }
  
      @Override
      public int getItemViewType(int position) {
          return position;
      }
  
      @Override
      public int getViewTypeCount() {
          if (al_menu.get(int_position).getAl_imagepath().size() &gt; 0) {
              return al_menu.get(int_position).getAl_imagepath().size();
          } else {
              return 1;
          }
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          if (convertView == null) {
  
              viewHolder = new ViewHolder();
              convertView = LayoutInflater.from(getContext()).inflate(R.layout.activity_adapter__photos_folder, parent, false);
              viewHolder.tv_foldern = (TextView) convertView.findViewById(R.id.tv_folder);
              viewHolder.tv_foldersize = (TextView) convertView.findViewById(R.id.tv_folder2);
              viewHolder.iv_image = (ImageView) convertView.findViewById(R.id.iv_image);
  
  
              convertView.setTag(viewHolder);
          } else {
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          viewHolder.tv_foldern.setVisibility(View.GONE);
          viewHolder.tv_foldersize.setVisibility(View.GONE);
  
  
  
          Glide.with(context).load("file://" + al_menu.get(int_position).getAl_imagepath().get(position))
                  .diskCacheStrategy(DiskCacheStrategy.NONE)
                  .skipMemoryCache(true)
                  .into(viewHolder.iv_image);
  
  
          return convertView;
  
      }
  
      private static class ViewHolder {
          TextView tv_foldern, tv_foldersize;
          ImageView iv_image;
  
  
      }
  }
  </code></pre>
  
  <p><strong>FullImageActivity.java</strong></p>
  
  <pre><code>public class FullImageActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_full_image);
  
          Intent i = getIntent();
  
          // Selected image id
          int position1 = i.getExtras().getInt("id");
  
          ImageView imageView = (ImageView) findViewById(R.id.fullImage);
          imageView.setImageResource();
          }
          }
  </code></pre>