我有一个类(foo)继承自ListActivity,它实例化了一个类(fooAdap)继承自ArrayAdapter。在fooAdap中,有一个getview()方法,我在其中填充我的ListView。
从foo类中,我可以调用getListView().setDividerHeight(0)并使分隔线消失。是否有一种方法可以从fooAdap的getView()方法中访问该方法?
foo.java
public class foo extends ListActivity
{
...
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
...
ListView lv = getListView ();
lv.setDividerHeight (0);
fooAdap foo = new fooAdap (this,android.R.layout.simple_list_item_single_choice, mRowData);
...
}
fooAdap.java
public class fooAdap extends ArrayAdapter
{
...
public View getView (int position, View convertView, ViewGroup parent)
{
...
switch (position)
{
case 1: // show divider for these rows in listview
case 2:
break;
case 3: // hide divider for this row in listview
break;
}
...
}
}