0

I referred here for making a gridview. Now what i want is if i touch one image in gridview it should link me to the next activity in the screen. Totally i have 5 images in my activity and if i touch those images every image needs to display five different activity. i tried this but couldn't do what i want. Can anyone tell me how to achieve this. Thanks in advance

4

2 回答 2

0
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView = new ImageView(mContext);
        imageView.setImageResource(mThumbIds[position]);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setLayoutParams(new GridView.LayoutParams(70, 70));

// USE this here and implement as acording by using 'position'
        imageView.setOnClickListener();
        return imageView;
    }
于 2013-10-04T06:25:56.810 回答
0

使用 Switch 语句并根据位置更改它。

     public void onCreate(Bundle savedInstanceState)
          {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.list);
            GridView gridview = (GridView) findViewById(R.id.gv);
            gridview.setAdapter(new ImageAdapter(this));

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
             switch(position)
                {
                case 0:               
                    Intent ammissione = (new Intent(List.this, Ammissione.class));             
                    startActivity(ammissione);
                    break;

                case 1:
                    Intent organizzazione = (new Intent(List.this, Organizzazione.class));             
                    startActivity(organizzazione);
                    break;

                case 2:
                    Intent notizie = (new Intent(List.this, Notizie.class));             
                    startActivity(notizie);
                     break;
                case 3:
                    Intent percorsi = (new Intent(List.this, Percorsi.class));             
                    startActivity(percorsi);

                case 4:
                    Intent didattica = (new Intent(List.this, Didattica.class));             
                    startActivity(didattica);
                    break;

                }


        }
    });
  }
于 2014-04-22T06:19:29.517 回答