title: Images is not shown in my Full screen Activity from my json response..? while swiping also
body: <p><strong>How to swipe my full screen images from gridview...and that images should Loading from JSON response...?</strong></p>
  
  <p>i'm new to android...please help me friends...</p>
  
  <p>But i want to use only <strong>One url</strong> in my program(<strong>JSON URL</strong>)...from that i need
  <strong>Gridview--->FullScreenImage(zooming and swiping)</strong></p>
  
  <p>This is my gridView Activity...</p>
  
  <pre><code>package com.example.admin.loadingimagefromwebgridandswipe;
  
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.res.Resources;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.util.TypedValue;
  import android.widget.GridView;
  import android.widget.ListView;
  
  import com.example.admin.adapter.GridViewImageAdapter;
  import com.example.admin.helper.AppConstant;
  import com.example.admin.helper.JSONfunctions;
  import com.example.admin.helper.Utils;
  import com.example.admin.ndimageslider.R;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  public class GridViewActivity extends Activity {
  
      private Utils utils;
      private ArrayList&lt;String&gt; imagePaths = new ArrayList&lt;String&gt;();
      private GridViewImageAdapter adapter;
      private GridView gridView;
      private int columnWidth;
  
  
      JSONObject jsonobject;
      JSONArray jsonarray;
      ProgressDialog mProgressDialog;
     // ArrayList&lt;HashMap&lt;String, String&gt;&gt; imagePaths;
      static String RANK = "rank";
      static String COUNTRY = "country";
      static String POPULATION = "population";
      static String FLAG = "flag";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_grid_view);
  
          gridView = (GridView) findViewById(R.id.grid_view);
  
          utils = new Utils(this);
  
          // Initilizing Grid View
          InitilizeGridLayout();
  
          new DownloadJSON().execute();
  
      }
  
      private void InitilizeGridLayout() {
          Resources r = getResources();
          float padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                  AppConstant.GRID_PADDING, r.getDisplayMetrics());
  
          columnWidth = (int) ((utils.getScreenWidth() -
                  ((AppConstant.NUM_OF_COLUMNS + 1) * padding)) / AppConstant.NUM_OF_COLUMNS);
  
          gridView.setNumColumns(AppConstant.NUM_OF_COLUMNS);
          gridView.setColumnWidth(columnWidth);
          gridView.setStretchMode(GridView.NO_STRETCH);
          gridView.setPadding((int) padding, (int) padding, (int) padding,
                  (int) padding);
          gridView.setHorizontalSpacing((int) padding);
          gridView.setVerticalSpacing((int) padding);
      }
  
      private class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              // Create a progressdialog
              mProgressDialog = new ProgressDialog(GridViewActivity.this);
              // Set progressdialog title
              mProgressDialog.setTitle("Android JSON Parse Tutorial");
              // Set progressdialog message
              mProgressDialog.setMessage("Loading...");
              mProgressDialog.setIndeterminate(false);
              // Show progressdialog
              mProgressDialog.show();
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              // Create an array
              imagePaths = new ArrayList&lt;&gt;();
              // Retrieve JSON Objects from the given URL address
              jsonobject = JSONfunctions
                      .getJSONfromURL("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors");
  
              try {
                  // Locate the array name in JSON
                  jsonarray = jsonobject.getJSONArray("actors");
  
                  for (int i = 0; i &lt; jsonarray.length(); i++) {
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                      jsonobject = jsonarray.getJSONObject(i);
                      // Retrive JSON Objects
                      imagePaths.add( jsonobject.getString("name"));
                      imagePaths.add(jsonobject.getString("country"));
                      imagePaths.add( jsonobject.getString("spouse"));
                      imagePaths.add(jsonobject.getString("image"));
                      // Set the JSON Objects into the array
                      // imagePaths.add(map);
                  }
              } catch (JSONException e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void args) {
              // Locate the listview in listview_main.xml
              gridView = (GridView) findViewById(R.id.grid_view);
              // Pass the results into ListViewAdapter.java
              adapter = new GridViewImageAdapter(GridViewActivity.this, imagePaths,columnWidth);
              // Set the adapter to the ListView
              gridView.setAdapter(adapter);
              // Close the progressdialog
              mProgressDialog.dismiss();
          }
      }
  
  }
  </code></pre>
  
  <p>this is my Gridview Adapter...</p>
  
  <pre><code>    package com.example.admin.adapter;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  import com.example.admin.loadingimagefromwebgridandswipe.FullScreenViewActivity;
  import com.squareup.picasso.Picasso;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.util.ArrayList;
  
  public class GridViewImageAdapter extends BaseAdapter {
  
      private Activity activity;
      private ArrayList&lt;String&gt; filePaths = new ArrayList&lt;String&gt;();
      private int imageWidth;
  
      public GridViewImageAdapter(Activity activity, ArrayList&lt;String&gt; filePaths,
                                  int imageWidth) {
          this.activity = activity;
          this.filePaths = filePaths;
          this.imageWidth = imageWidth;
      }
  
      @Override
      public int getCount() {
          return this.filePaths.size();
      }
  
      @Override
      public Object getItem(int position) {
          return this.filePaths.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ImageView imageView;
          if (convertView == null) {
              imageView = new ImageView(activity);
          } else {
              imageView = (ImageView) convertView;
          }
  
  
          String designationUrl = filePaths.get(position);
  //        Log.d("designationUrl",""+designationUrl);
  //        URL url = null;
  //        try {
  //            url = new URL(designationUrl);
  //        } catch (MalformedURLException e) {
  //            e.printStackTrace();
  //        }
  //        Bitmap bmp = null;
  //        try {
  //            bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
  //        } catch (IOException e) {
  //            e.printStackTrace();
  //        }
  
          Picasso.with(activity)
                  .load(designationUrl)
                  .resize(imageWidth, imageWidth).into(imageView);
  
  
          // image view click listener
          imageView.setOnClickListener(new OnImageClickListener(position));
          //Toast.makeText(GridViewImageAdapter.this,"url: "+designationUrl,Toast.LENGTH_LONG).show();
  
          return imageView;
      }
  
      class OnImageClickListener implements OnClickListener {
  
          int _postion;
  
          // constructor
          public OnImageClickListener(int position) {
              this._postion = position;
          }
  
          @Override
          public void onClick(View v) {
              // on selecting grid view image
              // launch full screen activity
            //  Toast.makeText(GridViewImageAdapter.this,"url: "+,Toast.LENGTH_LONG).show();
              Intent i = new Intent(activity, FullScreenViewActivity.class);
              i.putExtra("position", _postion);
              activity.startActivity(i);
          }
  
      }
  
      /*
       * Resizing image size
       */
      public static Bitmap decodeFile(String filePath, int WIDTH, int HIGHT) {
          try {
  
              File f = new File(filePath);
  
              BitmapFactory.Options o = new BitmapFactory.Options();
              o.inJustDecodeBounds = true;
              BitmapFactory.decodeStream(new FileInputStream(f), null, o);
  
              final int REQUIRED_WIDTH = WIDTH;
              final int REQUIRED_HIGHT = HIGHT;
              int scale = 1;
              while (o.outWidth / scale / 2 &gt;= REQUIRED_WIDTH
                      &amp;&amp; o.outHeight / scale / 2 &gt;= REQUIRED_HIGHT)
                  scale *= 2;
  
              BitmapFactory.Options o2 = new BitmapFactory.Options();
              o2.inSampleSize = scale;
              return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          return null;
      }
  
  }
  </code></pre>
  
  <p>Fullscreen imageViewActivity....</p>
  
  <pre><code>    package com.example.admin.loadingimagefromwebgridandswipe;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v4.view.ViewPager;
  import android.widget.ImageView;
  
  import com.example.admin.Application;
  import com.example.admin.adapter.FullScreenImageAdapter;
  import com.example.admin.helper.JSONfunctions;
  import com.example.admin.helper.Utils;
  import com.example.admin.ndimageslider.R;
  
  public class FullScreenViewActivity extends Activity{
  
      private Utils utils;
      private FullScreenImageAdapter adapter;
      private ViewPager viewPager;
      private ImageView flag;
  private  ImageView image;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_fullscreen_view);
  
          viewPager = (ViewPager) findViewById(R.id.pager);
  
          utils = new Utils(getApplicationContext());
          //flag=(ImageView)findViewById(R.id.flag);
          image=(ImageView)findViewById(R.id.image);
  
          Intent i = getIntent();
          int position = i.getIntExtra("position", 0);
          adapter = new FullScreenImageAdapter(FullScreenViewActivity.this,
                  Application.url());
          viewPager.setAdapter(adapter);
  
          // displaying selected image first
          viewPager.setCurrentItem(position);
          }
  }
  </code></pre>
  
  <p>FullScreenImageAdapter:</p>
  
  <pre><code> package com.example.admin.adapter;
  
  
  import android.app.Activity;
  import android.content.Context;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.RelativeLayout;
  
  import com.example.admin.helper.TouchImageView;
  import com.example.admin.ndimageslider.R;
  import com.squareup.picasso.Picasso;
  
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  
  public class FullScreenImageAdapter extends PagerAdapter {
  
      private Activity activity;
      private ArrayList&lt;String&gt; imagePaths;
      private LayoutInflater inflater;
  
      // constructor
      public FullScreenImageAdapter(Activity activity,
                                    ArrayList&lt;String&gt; imagePaths) {
          this.activity = activity;
          this.imagePaths = imagePaths;
      }
  
      @Override
      public int getCount() {
          return this.imagePaths.size();
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view == ((RelativeLayout) object);
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          TouchImageView imgDisplay;
          Button btnClose;
  
          inflater = (LayoutInflater) activity
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container,
                  false);
  
          imgDisplay = (TouchImageView) viewLayout.findViewById(R.id.imgDisplay);
          btnClose = (Button) viewLayout.findViewById(R.id.btnClose);
  
  //        BitmapFactory.Options options = new BitmapFactory.Options();
  //        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
  //        Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options);
  //        imgDisplay.setImageBitmap(bitmap);
  
          Picasso.with(activity)
                  .load(imagePaths.get(position)).into(imgDisplay);
  
          // close button click event
          btnClose.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  activity.finish();
              }
          });
  
          ((ViewPager) container).addView(viewLayout,0);
  
          return viewLayout;
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          ((ViewPager) container).removeView((RelativeLayout) object);
  
      }
  
  }
  </code></pre>
  
  <p>Application:</p>
  
  <pre><code>    package com.example.admin;
  
  import android.widget.Toast;
  
  import com.example.admin.helper.FileCache;
  
  import java.util.ArrayList;
  
  
  public class Application extends android.app.Application {
  
      public  static ArrayList&lt;String&gt; url(){
          ArrayList&lt;String&gt; filePaths = new ArrayList&lt;String&gt;();
  
         filePaths.add("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors");
  
  
  
  
          return filePaths;
      }
  }
  </code></pre>
  
  <p>JSONfunctions:</p>
  
  <pre><code>package com.example.admin.helper;
  
  /**
   * Created by Admin on 14-03-2016.
   */
  
  import android.util.Log;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.io.BufferedReader;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  
  public class JSONfunctions {
  
      public static JSONObject getJSONfromURL(String url) {
          InputStream is = null;
          String result = "";
          JSONObject jArray = null;
  
          // Download JSON data from URL
          try {
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost(url);
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
  
          } catch (Exception e) {
              Log.e("log_tag", "Error in http connection " + e.toString());
          }
  
          // Convert response to string
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              result = sb.toString();
          } catch (Exception e) {
              Log.e("log_tag", "Error converting result " + e.toString());
          }
  
          try {
  
              jArray = new JSONObject(result);
          } catch (JSONException e) {
              Log.e("log_tag", "Error parsing data " + e.toString());
          }
  
          return jArray;
      }
  }
  </code></pre>