I have a class (foo) extending ListActivity which instantiates a class (fooAdap) extending ArrayAdapter. In fooAdap, there is the getview() method where I populate my ListView.
From the foo class, I can call getListView().setDividerHeight(0) and make the divider disappear. Is there a way to access that method from getView() in fooAdap?
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;
}
...
}
}
I ended up making my own divider and setting the ListView dividerHeight() to 0 in the XML layout.
I have a separate layout for the ListView rows and added another LinearLayout and TextView there. I then copied the file divider_horizontal_dark.9.png from the android sdk directory into my res/ directory and set the background of the new TextView to it as well as setting MaxHeight to 1dp for the textview.
Now I can just toggle the LinearLayout to View.VISIBLE or View.GONE within getView() method. Long way around, but seems to get me what I want.