我有三个listview
,一个模型和自定义数组适配器。我正在尝试为所有三个listview
重复使用相同的自定义数组适配器和模型,并且每个listview
包含在getview
中加载的不同图像集。
有人能给我一个实现它的方法吗?
答案 0 :(得分: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);
答案 1 :(得分: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的适配器设置为所需的适配器。