0

我有 3 个listview,一个模型和自定义数组适配器。listview我正在尝试为所有三个s重新使用相同的自定义数组适配器和模型,每个都listview包含不同的图像集,这些图像被加载到getview.

有人可以给我一种实现它的方法吗?

4

2 回答 2

1

是的,您可以重复使用您的适配器。就像只看示例代码

customAdapter1 cusad1 = new customAdapter1 (YourActivity1.this,R.layout.row_list,yourlist1);
        list1.setAdapter(customAdapter1);

customAdapter2 cusad2 = new customAdapter2 (YourActivity2.this,R.layout.row_list,yourlist2);
        list2.setAdapter(customAdapter2);

customAdapter3 cusad3 = new customAdapter2 (YourActivity3.this,R.layout.row_list,yourlist3);
        list2.setAdapter(customAdapter3);
于 2012-10-09T10:52:09.810 回答
0

那里没什么难的...

MyArrayAdater myAdapter1= new MyArrayAdater (...myData for list 1....);
MyArrayAdater myAdapter2= new MyArrayAdater (...myData for list 2....);
MyArrayAdater myAdapter3= new MyArrayAdater (...myData for list 3....);

并将每个listView的adapter设置为你想要的Adapter。

于 2012-10-09T10:49:16.863 回答