我有一個類(foo)擴展ListActivity,它實例化一個類(fooAdap)擴展ArrayAdapter。在fooAdap中,有getview()方法,用於填充我的ListView。從ArrayAdapter類更改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;
}
...
}
}
我的答案可以幫助你,如果不是,請讓我知道我會爲你尋找這個。謝謝 – SALMAN 2012-07-20 08:11:07