简体   繁体   English

使用 class 数组在 GridView 内启动不同的活动

[英]using an array of class to launch different activities within GridView

I was reading the exapmle of GridView and I'd like to click on a picture and get an activity running so I tried to change the part related to Toast.... with a kind of class array but I think just got a mess...maybe someone get better result than my idea here's what I tried我正在阅读 GridView 的示例,我想单击一张图片并运行一个活动,所以我尝试更改与 Toast 相关的部分......使用一种 class 数组,但我认为只是一团糟。 ..也许有人得到比我的想法更好的结果这是我尝试过的

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

    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) {
           setClass(HelloGridView.this, classlist).startActivity(classlist);
       }
    });

    private integer [] classlist = {R.clip1, R.clip2, R.page3};
}

I am new to develop app so I just guess how to change this code Thank you for any suggestion我是开发应用程序的新手,所以我只是猜测如何更改此代码谢谢您的任何建议

ANgelo安杰洛

Please go through the link: http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views in that they are describing very well how to implement a grid view, gallery etc. As a fresher in development it helped me a lot.请通过链接go:http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views ,因为他们很好地描述了如何实现网格视图、画廊等。作为一个开发新手,它对我帮助很大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM