Skip to content

Commit

Permalink
StickyListHeadersListView now has its own styleable attribute.
Browse files Browse the repository at this point in the history
This allows users of this library to do things like:

values/themes.xml:
<resources>
  <style name="Theme.MyApp">
    <item name="stickyListHeadersListViewStyle">@style/Widget.MyApp.SomeStyle</item>
  </style>
</resources>
  • Loading branch information
zach-klippenstein committed Mar 28, 2015
1 parent 80e7105 commit 9252157
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
25 changes: 23 additions & 2 deletions README.md
Expand Up @@ -148,8 +148,29 @@ public class MyAdapter extends BaseAdapter implements StickyListHeadersAdapter {

That's it! Look through the API docs below to get know about things to customize and if you have any problems getting started please open an issue as it probably means the getting started guide need some improvement!

###Styling

You can apply your own theme to `StickyListHeadersListView`s. Say you define a style called `Widget.MyApp.ListView` in values/styles.xml:
```xml
<resources>
<style name="Widget.MyApp.ListView" parent="@android:style/Widget.ListView">
<item name="android:paddingLeft">@dimen/vertical_padding</item>
<item name="android:paddingRight">@dimen/vertical_padding</item>
</style>
</resources>
```

You can then apply this style to all `StickyListHeadersListView`s by adding something like this to your theme (e.g. values/themes.xml):
```xml
<resources>
<style name="Theme.MyApp" parent="android:Theme.NoTitleBar">
<item name="stickyListHeadersListViewStyle">@style/Widget.MyApp.ListView</item>
</style>
</resources>
```

###Expandable support
Now,you can use `ExpandableStickyListHeadersListView` to expand/collapse subitems.
Now, you can use `ExpandableStickyListHeadersListView` to expand/collapse subitems.
xml first
```xml
<se.emilsjolander.stickylistheaders.ExpandableStickyListHeadersListView
Expand All @@ -173,7 +194,7 @@ expandableStickyList.setOnHeaderClickListener(new StickyListHeadersListView.OnHe
}
});
```
As you see,MyAdapter is just a StickyListHeadersAdapter which is mentioned in the previous section.
As you see, MyAdapter is just a StickyListHeadersAdapter which is mentioned in the previous section.
You needn't do any more extra operations.

There are three important functions:
Expand Down
4 changes: 3 additions & 1 deletion library/res/values/attrs.xml
Expand Up @@ -2,6 +2,8 @@
<resources>

<declare-styleable name="StickyListHeadersListView">
<attr name="stickyListHeadersListViewStyle" format="reference"/>

<!-- View attributes -->
<attr name="android:clipToPadding" />
<attr name="android:scrollbars" />
Expand Down Expand Up @@ -32,4 +34,4 @@
<attr name="isDrawingListUnderStickyHeader" format="boolean" />
</declare-styleable>

</resources>
</resources>
Expand Up @@ -110,7 +110,7 @@ public StickyListHeadersListView(Context context) {
}

public StickyListHeadersListView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
this(context, attrs, R.attr.stickyListHeadersListViewStyle);
}

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
Expand All @@ -127,7 +127,7 @@ public StickyListHeadersListView(Context context, AttributeSet attrs, int defSty
mList.setDividerHeight(0);

if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.StickyListHeadersListView, 0, 0);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.StickyListHeadersListView, defStyle, 0);

try {
// -- View attributes --
Expand Down

0 comments on commit 9252157

Please sign in to comment.