Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:39:23+00:00 2026-05-27T06:39:23+00:00

I want to display some text below each grid image. Please see my code

  • 0

I want to display some text below each grid image.

Please see my code below.
Please help me in finding why its not working
I am getting the images properly displayed but no text
if i try to display text within image its coming
so it should be something with the layout defined. but i am not able to debug

adaptor code :

 public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
        LayoutInflater mInflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = mInflater.inflate(R.layout.griditems, null);
        holder = new ViewHolder();
    holder.text1 = (TextView) convertView
                .findViewById(R.id.grid_item_text);
    Log.i(TAG, holder.text1.toString());
        holder.image = (ImageView) convertView
                .findViewById(R.id.grid_item_image);


            // if it's not recycled, initialize some attributes
            holder.image.setImageResource(gridItemIds[position]);
            holder.text1.setText(gridTitles[position]);
        //holder.image.setScaleType(ImageView.ScaleType.FIT_XY);
        // holder.image.setPadding(20, 20, 20, 20);

    convertView.setLayoutParams(new GridView.LayoutParams(Utils
                .getLayoutParameter(), Utils.getLayoutParameter()));

        holder.image.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {

            }
        });
        convertView.setTag(holder);
    } else {

        holder = (ViewHolder) convertView.getTag();

    }

    return convertView;
}

static class ViewHolder {
    TextView text1;
    ImageView image;

}



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/GridItem"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:gravity="center_horizontal"
  >

   <ImageView android:id="@+id/grid_item_image"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
   </ImageView>

   <TextView android:id="@+id/grid_item_text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="TextView"
      android:textColor="#000000"
      >
   </TextView>

</LinearLayout>

gridview :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">


        <TextView android:id="@+id/text1view" android:textStyle="bold"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:gravity="center_horizontal" android:background="@drawable/title_bar" 
            />

        <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:verticalSpacing="50dip"
            android:horizontalSpacing="10dp" android:numColumns="3"
            android:stretchMode="columnWidth"
            android:layout_below="@+id/text1view" 
                         android:gravity="center"
            android:layout_centerHorizontal="true" 
            android:background="@drawable/home_bg"
                        />


</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:39:24+00:00Added an answer on May 27, 2026 at 6:39 am

    I used your xml but with a simple array adapter that I wrote and everything work perfectly, try to replace your adapter with mine and let me know, thanks.

    class ItemsAdapter extends ArrayAdapter<String> {
    
        public ItemsAdapter(Context context, List<String> list) {
            super(context, R.layout.griditems, list);
        }
    
        @Override
        public View getView(final int position, View row, final ViewGroup parent) {
            final String item = getItem(position);
    
            ItemWrapper wrapper = null;
            if (row == null) {
                row = getLayoutInflater().inflate(R.layout.griditems, parent, false);
                wrapper = new ItemWrapper(row);
    
                row.setTag(wrapper);
            } else {
                wrapper = (ItemWrapper) row.getTag();
            }
            wrapper.refreshData(item);
    
            return row;
        }
    
    }    
    
    static class ItemWrapper {
    
        TextView text;
        ImageView img;
    
        public ItemWrapper(View row) {
            text = (TextView) row.findViewById(R.id.grid_item_text);
            img = (ImageView) row.findViewById(R.id.grid_item_image);
        }
    
        public void refreshData(String item) {
            img.setImageResource(R.drawable.image_1);
            text.setText(item);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a section which has an image and some text below
I want to display some text on twitter/facebook when a link is clicked on
I have some text/images that I only want to display in the normal state
For the most part, when I want to display some HTML code to be
I want to display and edit some objects in a WPF data grid and
I'm having a problem with an image and some text. I have this code:
I want to display some QTextEdits over my main window at arbitrary locations. Below
I want to display some Arabic text from Right to Left. So I set
I am trying to display some text using MessageBox.Show as shown below in a
I received some amazing help from others, concerning finding and replacing text with jquery.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.