title: Gridview click not working inside the Custom Listview
body: <p>I'm using gridview inside a Listview, but I have a focusable problem.</p>
  <p>I have set the width of the gridview, but I fill some items of gridview, on the left space of gridview (which is blank) means items not fill of gridview in listview. If I click on it, it does not perform a listitem click</p>
  <p><img src="https://i.stack.imgur.com/v7sOG.png" alt="Enter image description here" /></p>
  <p><strong>As given in the image, I want to perform a listview item click if it is clicked anywhere in the list item. I want to get a listitem click</strong>.</p>
  <p>But when I click on <code>ListView</code> item, that is, <code>GridView</code> then the <code>ListItem</code> click is not working...</p>
  <pre><code>public class History extends Activity {
  
      String name, id, description, count, total;
  
      ArrayList&lt;String&gt; TAG_ID = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; TAG_COFFEESHOP_NAME = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; TAG_COUNT = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; TAG_TOTAL = new ArrayList&lt;String&gt;();
  
      Context context;
      JSONArray CoffeeUser = null;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.listlayout);
          ListView listView = (ListView) findViewById(R.id.listnew);
          listView.setAdapter(new MyCustomAdapter());
          listView.setTextFilterEnabled(true);
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
          {
              public void onItemClick(AdapterView&lt;?&gt; paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
              {
                  Intent intent = new Intent();
                  intent.putExtra(&quot;coffeeshopid&quot;, ((TextView)paramAnonymousView.findViewById(R.id.hlcoffeeshopid)).getText() );
                  intent.setClass(getParent(), Stamps.class);
                  HistoryStack hisStack = (HistoryStack) getParent();
                  hisStack.push(&quot;Stamps&quot;, intent);
              }
          });
      }
  
      class MyCustomAdapter extends BaseAdapter {
          Context ctx;
  
          public MyCustomAdapter() {
              // Creating JSON Parser instance
              JSONParser jParser = new JSONParser();
              SharedPreferences prfs = getSharedPreferences(&quot;GUID_FILE_NAME&quot;, Context.MODE_PRIVATE);
                  JSONObject json = jParser.methodhistory(&quot;http://api.com&quot;);
              try {
                  // Getting Array of Employee
                  CoffeeUser = json.getJSONArray(&quot;CoffeeUser&quot;);
  
                  // Looping of List
                  for (int i = 0; i &lt; CoffeeUser.length(); i++) {
                      JSONObject c = CoffeeUser.getJSONObject(i);
  
                      // Storing each json item in variable
                      id = c.getString(&quot;CS_Id&quot;);
                      name = c.getString(&quot;ShopName&quot;);
                      count = c.getString(&quot;totalstamps&quot;);
                      total = c.getString(&quot;threshholdcount&quot;);
  
                      // Adding all get values into array
                      if (name != &quot;null&quot;) {
                          TAG_COFFEESHOP_NAME.add(name);
                          TAG_ID.add(id);
                          TAG_TOTAL.add(total);
                          TAG_COUNT.add(count);
                      }
                  }
              }
              catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
          @Override
          public int getCount() {
              return TAG_COFFEESHOP_NAME.size();
          }
  
          @Override
          public Object getItem(int paramInt) {
              return TAG_COFFEESHOP_NAME.get(paramInt);
          }
  
          @Override
          public long getItemId(int paramInt) {
              return paramInt;
          }
  
          public class MyCustomHolder {
              public GridView localGrid;
              public TextView CoffeeShopName,coffeeshopsdescription,coffeeshopid;
          }
  
          @Override
          public View getView(int paramInt, View paramView,ViewGroup paramViewGroup) {
              View localView = paramView;
              MyCustomHolder holder = null;
              if (localView == null) {
                  LayoutInflater inflater = (LayoutInflater) History.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  localView = inflater.inflate(R.layout.historylist, null);
                  holder = new MyCustomHolder();
                  holder.CoffeeShopName = (TextView) localView.findViewById(R.id.hlcoffeeshopname);
                  holder.coffeeshopid = (TextView) localView.findViewById(R.id.hlcoffeeshopid);
                  holder.localGrid = (GridView) localView.findViewById(R.id.gridViewdistorylist);
                  localView.setTag(holder);
              }
              else {
                  holder = (MyCustomHolder) localView.getTag();
              }
              holder.CoffeeShopName.setText(TAG_COFFEESHOP_NAME.get(paramInt));
              holder.coffeeshopid.setText(TAG_ID.get(paramInt));
              holder.localGrid.setAdapter(new GridAdapterA(History.this, TAG_TOTAL.get(paramInt), TAG_COUNT.get(paramInt)));
              holder.localGrid.setFocusable(false);
              holder.localGrid.setFocusableInTouchMode(false);
              holder.CoffeeShopName.setFocusable(false);
              holder.CoffeeShopName.setFocusableInTouchMode(false);
              localView.setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                       Intent intent = new Intent();
                          intent.putExtra(&quot;coffeeshopid&quot;, ((TextView)v.findViewById(R.id.hlcoffeeshopid)).getText() );
                            intent.setClass(getParent(), Stamps.class);
                            HistoryStack hisStack = (HistoryStack) getParent();
                            hisStack.push(&quot;Stamps&quot;, intent);
                  }
              });
  
              return localView;
          }
      }
  
      public class GridAdapterA extends BaseAdapter {
  
          private Context context;
          String total,count;
  
          public GridAdapterA(Context context) {
              this.context = context;
          }
  
          public GridAdapterA(Context context, String total, String count) {
              // TODO Auto-generated constructor stub
              this.context = context;
              this.total = total;
              this.count = count;
          }
  
          public boolean areAllItemsEnabled()
          {
              return false;
          }
  
          public boolean isEnabled(int position)
          {
              return false;
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
  
              LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              View gridView;
  
              if (convertView == null) {
                  gridView = new View(context);
                  gridView = inflater.inflate(R.layout.customgrid_row, null);
                  gridView.setFocusable(false);
                  ImageView imageView = (ImageView) gridView.findViewById(R.id.grid_item_image);
                  imageView.setFocusable(false);
                  int i = 0;
                  if(count!=&quot;null&quot;)
                  i = Integer.parseInt(count);
  
                  if (position&lt;i ) {
                      //imageView.setImageResource(R.drawable.ii);
                      //    textView.setText(gridlist[position]);
                  }
                  else {
                      imageView.setImageResource(R.drawable.changedcup);
                      // textView.setText(&quot;&quot;);
                  }
              }
              else {
                  gridView = (View) convertView;
              }
              /*gridView.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent intent = new Intent();
                  intent.putExtra(&quot;coffeeshopid&quot;, ((TextView)v.findViewById(R.id.hlcoffeeshopid)).getText() );
                  intent.setClass(getParent(), Stamps.class);
                  HistoryStack hisStack = (HistoryStack) getParent();
                  hisStack.push(&quot;Stamps&quot;, intent);    }
              });*/
  
              return gridView;
          }
  
          @Override
          public int getCount() {
              int j=0;
              if(total!=&quot;null&quot;){
              j = Integer.parseInt(total);
              }
              return j;
          }
  
          @Override
          public Object getItem(int position) {
              return null;
          }
  
          @Override
          public long getItemId(int position) {
              return 0;
          }
      }
  }
  </code></pre>
  <p><strong>historylist</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;@drawable/list_selector&quot;
      android:orientation=&quot;horizontal&quot;
      android:padding=&quot;5dip&quot; &gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/thumbnail&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentLeft=&quot;true&quot;
          android:layout_marginRight=&quot;5dip&quot;
          android:background=&quot;@drawable/image_bg&quot;
          android:padding=&quot;3dip&quot; &gt;
  
          &lt;ImageView
              android:id=&quot;@+id/list_image&quot;
              android:layout_width=&quot;50dip&quot;
              android:layout_height=&quot;50dip&quot;
              android:src=&quot;@drawable/rcup&quot; /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;!-- hlcoffeeshopname Of Song --&gt;
  
      &lt;TextView
          android:id=&quot;@+id/hlcoffeeshopname&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignTop=&quot;@+id/thumbnail&quot;
          android:layout_toRightOf=&quot;@+id/thumbnail&quot;
          android:text=&quot;Rihanna Love the way lie&quot;
          android:textColor=&quot;#040404&quot;
          android:textSize=&quot;20dip&quot;
          android:textStyle=&quot;bold&quot;
          android:typeface=&quot;sans&quot; /&gt;
  
      &lt;TextView
         android:id=&quot;@+id/hlcoffeeshopid&quot;
         android:layout_width=&quot;wrap_content&quot;
         android:layout_height=&quot;wrap_content&quot;
         android:visibility=&quot;gone&quot;
      /&gt;
  
      &lt;GridView
          xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          android:id=&quot;@+id/gridViewdistorylist&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;40dp&quot;
          android:layout_below=&quot;@+id/hlcoffeeshopname&quot;
          android:layout_toRightOf=&quot;@+id/thumbnail&quot;
          android:columnWidth=&quot;20dp&quot;
          android:background=&quot;@null&quot;
          android:descendantFocusability=&quot;blocksDescendants&quot;
          android:focusable=&quot;false&quot;
          android:focusableInTouchMode=&quot;false&quot;
          android:numColumns=&quot;10&quot;
          android:stretchMode=&quot;none&quot; &gt;
      &lt;/GridView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  <h3>New GetView</h3>
  <pre><code>@Override
      public View getView(int paramInt,
                          View paramView,
                          ViewGroup paramViewGroup) {
          View localView = paramView;
          MyCustomHolder holder = null;
          if (localView == null) {
              LayoutInflater inflater = (LayoutInflater) CopyOfHistory.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              localView = inflater.inflate(R.layout.copyhistorylist, null);
              holder = new MyCustomHolder();
              holder.coffeeShopName = (TextView) localView.findViewById(R.id.hlcoffeeshopname);
              holder.coffeeshopid = (TextView) localView.findViewById(R.id.hlcoffeeshopid);
              localView.setTag(holder);
          }
          else {
              holder = (MyCustomHolder) localView.getTag();
          }
          holder.coffeeShopName.setText(TAG_COFFEESHOP_NAME.get(paramInt));
          holder.coffeeshopid.setText(TAG_ID.get(paramInt));
  
          int looplimit = Integer.parseInt(TAG_TOTAL.get(paramInt));
          for (int i = 0; i &lt; looplimit; i++) {
              Log.e(&quot;loop&quot;, String.valueOf(looplimit));
              ImageView imageView = new ImageView(CopyOfHistory.this);
              if (i &lt; Integer.parseInt(TAG_COUNT.get(paramInt))) {
                  imageView.setImageDrawable(getResources().getDrawable(R.drawable.ii));
              } else {
                  imageView.setImageDrawable(getResources().getDrawable(R.drawable.iii));
              }
              RelativeLayout layout = (RelativeLayout) localView.findViewById(R.id.hlrlayout);
              RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(30,30);
              params.setMargins(i*40, 0, 0, 0);
              imageView.setLayoutParams(params);
              layout.addView(imageView);
              //holder.relativeLayout = new RelativeLayout();
          }
  
          holder.coffeeShopName.setFocusable(false);
          holder.coffeeShopName.setFocusableInTouchMode(false);
          localView.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent intent = new Intent();
                  intent.putExtra(&quot;coffeeshopid&quot;, ((TextView) v
                          .findViewById(R.id.hlcoffeeshopid)).getText());
                  intent.setClass(getParent(), Stamps.class);
                  HistoryStack hisStack = (HistoryStack) getParent();
                  hisStack.push(&quot;Stamps&quot;, intent);
              }
          });
  
          return localView;
      }
  </code></pre>