0


I use this tutorial:
Tutorial

To show me a image into gridview,very good,but this tutorial show me image and text for example google but i want just show me image,and when i delete this line on code:

public CustomGrid(Context c,String[] web,int[] Imageid ) {
    mContext = c;
    this.Imageid = Imageid;
    this.web = web;
}

i delete the String[] web but when i run my app is crash and exit the program.
How can i delete the text on gridview and just show to me image?

1
  • what errors you are getting ? Commented Aug 27, 2014 at 9:20

2 Answers 2

1

First do the changes mention by Dhruti after that try these, If you do not want title strings means remove this constructor

public CustomGrid(Context c,String[] web,int[] Imageid ) {
          mContext = c;
          this.Imageid = Imageid;
          this.web = web;
      }

and change like below

public CustomGrid(Context c,int[] Imageid ) {
          mContext = c;
          this.Imageid = Imageid;
      }

Change adapter's getView() like below,

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      View grid;
      LayoutInflater inflater = (LayoutInflater) mContext
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          if (convertView == null) {
            grid = new View(mContext);
            grid = inflater.inflate(R.layout.grid_single, null);
            ImageView imageView = (ImageView)grid.findViewById(R.id.grid_image);

            imageView.setImageResource(Imageid[position]);
          } else {
            grid = (View) convertView;
          }
      return grid;
    }
Sign up to request clarification or add additional context in comments.

2 Comments

I write your code but when remove the String[] web,they have a this error:the blank final web may be not initialized
just remove private final String[] web;
1

You need to remove text, so you should remove it firstly from your layout.xml

<TextView
    android:id="@+id/grid_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:textSize="9sp" >
</TextView>

Remove this. and all references to grid_text from java code, too.

Even after that if you get crash, show logcat.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.