title: Android - clickable items from JSON
body: <p>I know there are many similar questions and answers here, but nothing worked for my case.</p>
  
  <p>I created a simple JSON list using fragment - according to this tutorial <a href="http://androidbeginnerstutorial.blogspot.sk/2015/06/json-parsing-using-fragment-with.html" rel="nofollow noreferrer">http://androidbeginnerstutorial.blogspot.sk/2015/06/json-parsing-using-fragment-with.html</a></p>
  
  <p>It is working fine, but I want to have all items from the list clickable, so after click another page appears with some more info from the same JSON.</p>
  
  <p>I tried to implement to ActorAdapter.java inside</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  </code></pre>
  
  <p>I created something like </p>
  
  <pre><code> itemView.setOnClickListener(new OnClickListener() {
  Intent intent = new Intent(context, SingleitemView.class);
  })
  </code></pre>
  
  <p>but not sure what else to put there to get it work.</p>
  
  <p>I have already created the SingleitemView class.</p>
  
  <p>Can you please help me? Thank you.</p>
  
  <p>Here is my code from ActorAdapter.java:</p>
  
  <pre><code>import java.io.InputStream;
  import java.util.ArrayList;
  
  import java.util.HashMap;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.AsyncTask;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.widget.ListView;
  
  public class ActorAdapter extends ArrayAdapter&lt;Actors&gt; {
      ArrayList&lt;Actors&gt; actorList;
      LayoutInflater vi;
      int Resource;
      ViewHolder holder;
  
  
      public ActorAdapter(Context context, int resource, ArrayList&lt;Actors&gt; objects) {
          super(context, resource, objects);
          vi = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          Resource = resource;
          actorList = objects;
      }
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          // convert view = design
          View v = convertView;
          if (v == null) {
              holder = new ViewHolder();
              v = vi.inflate(Resource, null);
              holder.imageview = (ImageView) v.findViewById(R.id.ivImage);
              holder.tvName = (TextView) v.findViewById(R.id.tvName);
              holder.tvDescription = (TextView) v.findViewById(R.id.tvDescriptionn);
              holder.tvDOB = (TextView) v.findViewById(R.id.tvDateOfBirth);
              holder.tvCountry = (TextView) v.findViewById(R.id.tvCountry);
              holder.tvHeight = (TextView) v.findViewById(R.id.tvHeight);
              holder.tvSpouse = (TextView) v.findViewById(R.id.tvSpouse);
              holder.tvChildren = (TextView) v.findViewById(R.id.tvChildren);
              v.setTag(holder);
          } else {
              holder = (ViewHolder) v.getTag();
          }
          holder.imageview.setImageResource(R.drawable.ic_launcher);
          new DownloadImageTask(holder.imageview).execute(actorList.get(position).getImage());
          holder.tvName.setText(actorList.get(position).getName());
          holder.tvDescription.setText(actorList.get(position).getDescription());
          holder.tvDOB.setText("B'day: " + actorList.get(position).getDob());
          holder.tvCountry.setText(actorList.get(position).getCountry());
          holder.tvHeight.setText("Height: " + actorList.get(position).getHeight());
          holder.tvSpouse.setText("Spouse: " + actorList.get(position).getSpouse());
          holder.tvChildren.setText("Children: " + actorList.get(position).getChildren());
  
  
  
     v.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
  
          Intent intent = new Intent(view.getContext(), SingleitemView.class);
          intent.putExtra("name", "XXXXXX");
          view.getContext().startActivity(intent);
      }
  });
  
          return v;
  
      }
  
  
  
      static class ViewHolder {
          public ImageView imageview;
          public TextView tvName;
          public TextView tvDescription;
          public TextView tvDOB;
          public TextView tvCountry;
          public TextView tvHeight;
          public TextView tvSpouse;
          public TextView tvChildren;
  
      }
  
      private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
          ImageView bmImage;
  
          public DownloadImageTask(ImageView bmImage) {
              this.bmImage = bmImage;
          }
  
          protected Bitmap doInBackground(String... urls) {
              String urldisplay = urls[0];
              Bitmap mIcon11 = null;
              try {
                  InputStream in = new java.net.URL(urldisplay).openStream();
                  mIcon11 = BitmapFactory.decodeStream(in);
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return mIcon11;
          }
  
          protected void onPostExecute(Bitmap result) {
  
              bmImage.setImageBitmap(result);
          }
  
      }
  }
  </code></pre>
  
  <p>and the SingleitemView.java - that is supposed to be the new activity after click</p>
  
  <pre><code>    import android.app.Activity;
          import android.content.Intent;
          import android.os.Bundle;
          import android.widget.TextView;
  
  
  public class SingleitemView extends Activity {
  // Declare Variables
  String name;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      // Get the view from singleitemview.xml
      setContentView(R.layout.singleitemview);
  
      Intent i = getIntent();
      // Get the result of rank
      name = i.getStringExtra("name");
  
  
      // Locate the TextViews in singleitemview.xml
      TextView txtname = (TextView) findViewById(R.id.name);
  
  
      // Set results to the TextViews
      txtname.setText(name);
  
  }
  </code></pre>
  
  <p>}</p>