title: gridview inside sherlockfragment cannot perform onItemClick
body: <p>I have seen many post regarding this but cannot understand y my code doesn't work.</p>
  
  <p>i have a gridview in SherlockFragment and i updating the gridview items in an asyncTask.</p>
  
  <p>Here is my xml for gridView,</p>
  
  <pre><code>&lt;GridView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/gridview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center"
  android:horizontalSpacing="4dip"
  android:numColumns="auto_fit"
  android:stretchMode="columnWidth"
  android:verticalSpacing="10dip"
  android:padding="4dip"
  android:background="#000000"
   /&gt;
  </code></pre>
  
  <p>and GridView items xml is.</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="140dp"
  android:layout_height="150dp"
  android:paddingLeft="4dp"
  android:paddingTop="4dp" &gt;
  
  &lt;ImageView
      android:id="@+id/cat_thumbnail"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:contentDescription="@string/content_description"
      android:scaleType="fitXY"
      android:src="@drawable/logo" /&gt;
  
  &lt;TextView
      android:id="@+id/cat_title"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/cat_thumbnail"
      android:background="#80a0a0a0"
      android:text="Medium Text"
      android:textAppearance="?android:attr/textAppearanceMedium"
      android:textColor="#ffffff" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>and the code that i am using is.,</p>
  
  <pre><code>extends SherlockFragment {
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      final View v = inflater.inflate(R.layout.grid_layout, container, false);
      gridView = (GridView) (v.findViewById(R.id.gridview));
      return v;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      imageLoader = ImageLoader.getInstance();
      setHasOptionsMenu(false);
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      setRetainInstance(true);
      CategoryItems = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      new GridImages().execute();
      gridView.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
  
              HashMap&lt;String, String&gt; tempMap = new HashMap&lt;String, String&gt;();
              tempMap = CategoryItems.get(position);
              String Catid = tempMap.get(TAG_ID);
              Fragment videoFragment = new VideosFragment();
              Bundle bundle = new Bundle();
              bundle.putString(TAG_ID, Catid);
              videoFragment.setArguments(bundle);
              FragmentChangeActivity fca = (FragmentChangeActivity) getActivity();
              fca.switchContent(videoFragment);
          }
      });
  
  }
  
  public class ImageAdapter extends BaseAdapter {
  
      public class ViewHolder {
          public TextView title;
          public ImageView thumbnail;
      }
  
      private Context mContext;
  
      public ImageAdapter(Context ctx) {
          mContext = ctx;
      }
  
      @Override
      public int getCount() {
          return imageUrls.length;
      }
  
      @Override
      public Object getItem(int position) {
          return null;
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = convertView;
          final ViewHolder holder;
          if (convertView == null) {
              view = LayoutInflater.from(mContext).inflate(
                      R.layout.category_list_row, parent, false);
              holder = new ViewHolder();
              holder.title = (TextView) view.findViewById(R.id.cat_title);
              holder.title.setSelected(false);
              holder.thumbnail = (ImageView) view
                      .findViewById(R.id.cat_thumbnail);
              holder.thumbnail.setSelected(false);
  
              view.setTag(holder);
  
          } else {
              holder = (ViewHolder) view.getTag();
              view=(View) convertView;
              view.setTag(holder);
          }
          HashMap&lt;String, String&gt; tempMap = new HashMap&lt;String, String&gt;();
  
          tempMap = CategoryItems.get(position);
          holder.title.setText(tempMap.get(TAG_NAME));
          imageLoader.displayImage(imageUrls[position], holder.thumbnail,
                  defaultOptions);
                      holder.title.setOnClickListener(forItemClick);
          holder.thumbnail.setOnClickListener(forItemClick);
          return view;
      }
  }
    private OnClickListener forItemClick=new OnClickListener() {
  
      @Override
      public void onClick(View v) {
          Toast.makeText(getActivity(), "kjsdhkfds", Toast.LENGTH_LONG).show();
      }
  };
  
  class GridImages extends AsyncTask&lt;Void, Void, Void&gt; {
      ProgressDialog dialog = new ProgressDialog(
              CategoryFragment.this.getActivity());
  
      @Override
      protected Void doInBackground(Void... params) {
          parsing();
          return null;
      }
  
      protected void onPreExecute() {
          dialog.setMessage("Please wait...");
          dialog.setIndeterminate(true);
          dialog.show();
      }
  
      protected void onPostExecute(Void unused) {
          gridView.setAdapter(new ImageAdapter(getActivity()));
          dialog.dismiss();
      }
  
  }
  
  private void parsing() {
      JSONParser jParser = new JSONParser();
      JSONObject json = jParser.getJSONFromUrl(url.trim());
      try {
          JSONObject Collection = json.getJSONObject(TAG_HEADER);
          Category = Collection.getJSONArray(TAG_CATEGORY);
          for (int i = 0; i &lt; Category.length(); i++) {
              JSONObject temp = Category.getJSONObject(i);
              String id = temp.getString(TAG_ID);
              String name = temp.getString(TAG_NAME);
              String thumbnail = temp.getString(TAG_THUMBNAIL);
  
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
              map.put(TAG_ID, id);
              map.put(TAG_NAME, name);
              map.put(TAG_THUMBNAIL, thumbnail);
  
              CategoryItems.add(map);
          }
  
      } catch (JSONException e) {
          e.printStackTrace();
      }
      int i = 0;
      imageUrls = new String[CategoryItems.size()];
      for (HashMap&lt;String, String&gt; map : CategoryItems) {
          imageUrls[i] = map.get(TAG_THUMBNAIL).trim();
          System.out.println(imageUrls[i]);
          i++;
      }
      defaultOptions = new DisplayImageOptions.Builder().cacheInMemory()
              .showStubImage(R.drawable.logo).resetViewBeforeLoading()
              .cacheOnDisc().build();
  
      config = new ImageLoaderConfiguration.Builder(getActivity()
              .getApplicationContext()).defaultDisplayImageOptions(
              defaultOptions).build();
      imageLoader.init(config);
  }
  </code></pre>
  
  <p>please tell me what i am doing wrong., i cannot find it.,</p>
  
  <p>i cannot perform onClick event for my gridView.</p>
  
  <p>I <strong>I have updated my code now works., but this will not be the final solution i think because i didn't made the gridview clickable.valuable comments are expected always Thaks @Dhaval Sodha Parmar.,</strong></p>