NoSuchMethod exception for setShowDividers
Asked Answered
P

1

2

I would like to display a sort of ListView with divider lines between each item. Because each row of this list will show a different custom view I thought it would be easier to have a TableLayout instead and use setShowDividers and SHOW_DIVIDER_MIDDLE in order to show that white line between each item.

Why do I get NoSuchMethod exception at setShowDividers?

 TableLayout table = (TableLayout)findViewById(R.id.my_table_layout);
 if( table != null )
 {
      table.setShowDividers(TableLayout.SHOW_DIVIDER_MIDDLE);
 }

I also get the same error if I cast everything to LinearLayout instead.

Pangenesis answered 29/11, 2011 at 0:17 Comment(0)
G
3

What API target are you using? setShowDividers was added in API level 11 (Honeycomb).

Gundry answered 29/11, 2011 at 0:20 Comment(4)
OH okay, I was using level 10, thank-you I no longer get this exception. However I do not see any divider lines between table rows? Do I have to supply a resource or anything for this to work?Pangenesis
I think so, but I've not used it personally. The TableLayout docs show a setDividerDrawable(Drawable) method that should do what you need.Gundry
Okay, I tried setting the drawable and it does something but certainly does not look right..! I guess this is a separate issue, but yes I needed a later API, thxPangenesis
@Pangenesis you can use IcsLinearLayout that is in ActionBarSherlock if you wish, but do note that it's not intended to be used. there is also LinearLayoutICS which is in the support libraryStriptease

© 2022 - 2024 — McMap. All rights reserved.