1

我有三个选项卡,每个选项卡的内容都是一个视图(在本例中为 Gridview)。我创建了一个图像适配器类来填充网格。我调用图像适配器使用

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

但是每个视图必须以不同的方式填充。我怎么知道哪个视图称为图像适配器类?是否有一种方法可以将参数与调用一起传递,或者可以以不同的方式完成吗?

4

2 回答 2

1

尝试在您的网格适配器类中创建一个构造函数,并尝试将数组与上下文一起传递

于 2011-06-23T04:05:39.677 回答
0
Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost

    Intent intent = new Intent(this, a0.class);
    tabHost.addTab(tabHost.newTabSpec("")
            .setIndicator("", res.getDrawable(R.drawable.ic_tab_main))
            .setContent(intent));

    Intent intent2 = new Intent(this, c0.class);
    tabHost.addTab(tabHost
            .newTabSpec("")
            .setIndicator("", res.getDrawable(R.drawable.ic_tab_setup))
            .setContent(intent2));

    Intent intent3 = new Intent(this, d0.class);
    tabHost.addTab(tabHost
            .newTabSpec("")
            .setIndicator("", res.getDrawable(R.drawable.ic_tab_third))
            .setContent(intent3));
    Intent intent4 = new Intent(this, e0.class);
    tabHost.addTab(tabHost
            .newTabSpec("")
            .setIndicator("", res.getDrawable(R.drawable.ic_tab_setting))
            .setContent(intent4));

    tabHost.setCurrentTab(0);

    // Set tabs Colors
    tabHost.setBackgroundColor(Color.BLACK);
    tabHost.getTabWidget().setBackgroundColor(Color.BLACK);
于 2011-06-20T07:02:51.303 回答