title: How to make grid-view horizontally scrollable in android
body: <p>I have written code for gridview in which i can show image and text but i want to show all image in single scrollable row like Pulse news apps.
  I have implemented horizontalscroll-view for gridview in xml but it does not work at all.
  I am using pageviwer for tabs and i am using fragments.</p>
  
  <p>Here is my xml code</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
     &lt;HorizontalScrollView 
     android:id="@+id/horizontalScrollView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"
     android:fillViewport="true"
     android:scrollbars="horizontal" &gt;
  &lt;GridView
      android:layout_width="500dp"
      android:layout_height="400dp"
      android:id="@+id/gridview"
      android:columnWidth="300dp"
      android:numColumns="3"
      android:horizontalSpacing="10dp"
      android:scrollbars="horizontal"&gt;
  &lt;/GridView&gt;
   &lt;/HorizontalScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is my image adpator code</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
  private Context context;
  private final String[] mobileValues;
  private TextView t;
  public ImageAdapter(Context context, String[] mobileValues) {
      this.context = context;
      this.mobileValues = mobileValues;
  }
  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);
          // get layout from mobile.xml
          gridView = inflater.inflate(R.layout.showlist_item, null);
         // set value into textview
          TextView textView = (TextView) gridView
                  .findViewById(R.id.grid_item_label);
          textView.setText(mobileValues[position]);
          // set image based on selected text
          ImageView imageView = (ImageView) gridView
                  .findViewById(R.id.grid_item_image);
          String mobile = mobileValues[position];
          if (mobile.equals("Windows")) {
              imageView.setImageResource(R.drawable.test_play_image);
          } else if (mobile.equals("iOS")) {
              imageView.setImageResource(R.drawable.test_play_image);
          } else if (mobile.equals("Blackberry")) {
              imageView.setImageResource(R.drawable.test_play_image);
          } else {
              imageView.setImageResource(R.drawable.test_play_image);
          }
      } else {
          gridView = (View) convertView;
      }
      return gridView;
  }
  private void clickedButton(TextView tv){
      int num = Integer.parseInt(tv.getText().toString());
      ++num;
      tv.setText(Integer.toString(num));
  }
  private void clickedButtonm(TextView tv){
      int num = Integer.parseInt(tv.getText().toString());
      if(num&gt;0){
          --num;
          tv.setText(Integer.toString(num));
      }
  }
  public int getCount() {
      return mobileValues.length;
  }
  public Object getItem(int position) {
      return null;
  }
  public long getItemId(int position) {
      return 0;
  }
  class MyOnClickListener implements OnClickListener{
      public final TextView tv;
      public MyOnClickListener(TextView tv){
          this.tv=tv;
      }
      public void onClick(View v) {
          // TODO Auto-generated method stub
          clickedButton(tv);
      }
  }
  class MyOnClickListenerm implements OnClickListener{
      public final TextView tv;
      public MyOnClickListenerm(TextView tv){
          this.tv=tv;
      }
      public void onClick(View v) {
          // TODO Auto-generated method stub
          clickedButtonm(tv);
      }
  }
  </code></pre>
  
  <p>I want to display like this scrollable to right.
  <img src="https://i.stack.imgur.com/g8BHf.png" alt="enter image description here"></p>