Hi this is example code for your doubt:

public class GridImg extends Activity {
     public static Integer[] DATA =
{R.drawable.page1,R.drawable.page2,R.drawable.page3,R.drawable.page4};

    @Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

        setContentView(R.layout.gridimg);

        GridView g = (GridView) findViewById(R.id.GridView01);
        g.setAdapter(new TextAdapter(this));
        g.setOnItemClickListener(new OnItemClickListener(){

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
                // TODO Auto-generated method stub
                //Toast.makeText(getBaseContext(),"You've got an
event",Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(GridImg.this,Next.class);
                Bundle bundle=new Bundle();
                bundle.putInt("key", position);
                intent.putExtras(bundle);
                startActivity(intent);
            }

        });
    }


With regards,
Yazhini

On Thu, Jan 20, 2011 at 1:32 PM, Trung Liem Vo <[email protected]> wrote:

> Hi,
>
> Your code is correct.
>
> Can you use each item contain imageview and textview. So your image will
> have the label.
>
> Best regards,
> Trung Liem Vo
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of pramod.deore
> Sent: Thursday, January 20, 2011 11:40 AM
> To: Android Developers
> Subject: [android-developers] add text to each image in gridview
>
> Hi, everybody
>
>          I want to add label for each image in gridview how to do
> this? I had tried with following code but it shows only images and not
> text.
>
> my xml file as:
>
> <?xml version="1.0" encoding="utf-8"?>
> <GridView xmlns:android="http://schemas.android.com/apk/res/android";
>    android:id="@+id/myGrid"
>    android:text="Pramod"
>    android:layout_width="fill_parent"
>    android:layout_height="fill_parent"
>
>    android:columnWidth="90dp"
>    android:numColumns="auto_fit"
>    android:verticalSpacing="10dp"
>    android:horizontalSpacing="10dp"
>    android:stretchMode="columnWidth"
>    android:gravity="center"
>
> />
>
> how to do this.
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to