Hi,

Thanks for the reply. Yes, I used the GridView and
SetOnItemClickListener. Now am able to click on any icon and display
the details on other screen. I have a second screen or activity,
clicking on first icon it should open the second screen and clicking
on second icon it should open the third screen . But now when I click
on any icon, the same second screen is displayed. I am using intents.
So I am not getting how to achieve this? Could you please help me.

This is my code:

package com.android.grid_hello;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;
import android.content.Intent;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;

public class grid_hello extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_new);

        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(this));

        gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int
position, long id) {

                Intent intent1 = new
Intent(grid_hello.this,second.class);
                startActivity(intent1);
            }
        });
    }

    public class ImageAdapter extends BaseAdapter {
        private Context mContext;

        public ImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return mThumbIds.length;
        }

        public Object getItem(int position) {
            return null;
        }

        public long getItemId(int position) {
            return 0;
        }

        // create a new ImageView for each item referenced by the
Adapter
        public View getView(int position, View convertView, ViewGroup
parent) {
            ImageView imageView;
            if (convertView == null) {  // if it's not recycled,
initialize some attributes
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new
GridView.LayoutParams(85, 85));
 
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView.setPadding(8, 8, 8, 8);
            } else {
                imageView = (ImageView) convertView;
            }

            imageView.setImageResource(mThumbIds[position]);
            return imageView;
        }

        // references to our images
        private Integer[] mThumbIds = {
                R.drawable.sample_0, R.drawable.sample_1,
                R.drawable.sample_2, R.drawable.sample_3,
                R.drawable.sample_4, R.drawable.sample_5,
                R.drawable.sample_6, R.drawable.sample_7,
            };
    }

}

On Mar 11, 10:08 pm, Makas Tzavellas <[email protected]>
wrote:
> Sounds like you want to use a GridView, create a custom adapter that
> returns an ImageView and set OnItemClickListener to activate your
> desired behaviour.
>
> You would probably want to take a look at the API Demos that uses
> ListViews for some examples.
>
> On Mar 11, 5:55 pm, NewDev <[email protected]> wrote:
>
> > Hi,
>
> > I want to write an android application, that should have a homepage or
> > home screen and having many utilities. Each utility should have an
> > icon with the name. So clicking on each utility or the icon, the
> > corresponding next screen should be displayed. It should be similar to
> > the android home screen. Is there any sample application that i can
> > refer? Could anybody please let me know, how to set the icons for the
> > utilities in the homepage of my application.
>
> > Thanks in advance,
>
> > NewDev
>
>

-- 
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