title: Onclick Listener Gridview does not work in Fragment
body: <p>I have 3 fragments with gridview but onclikitem event does not work.</p>
  
  <p>What might be the problem?</p>
  
  <p>I did my best and I tried all of them but not true. I think the problem is the use of fragments because with use activity works fine.</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.free_video_fragment, container, false);
  final GridView gridview = (GridView) view.findViewById(R.id.freevideogridview);
  List&lt;ItemObject&gt; allItems = getAllItemObject();
  CustomAdapter customAdapter = new CustomAdapter(getActivity(), allItems);
  gridview.setAdapter(customAdapter);
  gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
   public void onItemClick(AdapterView&lt;?&gt; parent, final View view, final int position, long id) {
  Toast.makeText(getActivity(),"Position" , Toast.LENGTH_LONG).show();
     }
      });
      return view;
  </code></pre>
  
  <p>Layout:</p>
  
  <pre><code>&lt;GridView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/freevideogridview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center"
      android:horizontalSpacing="4dp"
      android:numColumns="3"
      android:padding="4dp"
      android:scrollbars="none"
      android:stretchMode="columnWidth"
      android:verticalSpacing="4dp"
  
     /&gt;
  </code></pre>
  
  <p>Adapter:</p>
  
  <pre><code>public class CustomAdapter extends BaseAdapter {
  
      private LayoutInflater layoutinflater;
      private List&lt;ItemObject&gt; listStorage;
      private Context context;
  
      public CustomAdapter(Context context, List&lt;ItemObject&gt; customizedListView) {
          this.context = context;
          layoutinflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          listStorage = customizedListView;
      }
  
      @Override
      public int getCount() {
          return listStorage.size();
      }
  
      @Override
      public Object getItem(int position) {
          return position;
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          ViewHolder listViewHolder;
          if(convertView == null){
              listViewHolder = new ViewHolder();
              convertView = layoutinflater.inflate(R.layout.pop_music_list, parent, false);
              listViewHolder.screenShot = (ImageView)convertView.findViewById(R.id.screen_shot);
              listViewHolder.musicName = (TextView)convertView.findViewById(R.id.music_name);
              listViewHolder.musicAuthor = (TextView)convertView.findViewById(R.id.music_author);
  
              convertView.setTag(listViewHolder);
          }else{
              listViewHolder = (ViewHolder)convertView.getTag();
          }
          listViewHolder.screenShot.setImageResource(listStorage.get(position).getScreenShot());
          listViewHolder.musicName.setText(listStorage.get(position).getMusicName());
          listViewHolder.musicAuthor.setText(listStorage.get(position).getMusicAuthor());
  
          return convertView;
      }
  
      static class ViewHolder{
          ImageView screenShot;
          TextView musicName;
          TextView musicAuthor;
      }
  
  }
  </code></pre>