Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsunhua/StickyRecyclerSettingView
A Fast Way to build a SettingActivity with RecyclerView on Android
https://github.com/tsunhua/StickyRecyclerSettingView
Last synced: about 1 month ago
JSON representation
A Fast Way to build a SettingActivity with RecyclerView on Android
- Host: GitHub
- URL: https://github.com/tsunhua/StickyRecyclerSettingView
- Owner: tsunhua
- Created: 2016-11-02T13:28:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-30T07:21:33.000Z (about 8 years ago)
- Last Synced: 2024-05-22T06:11:55.343Z (7 months ago)
- Language: Java
- Homepage:
- Size: 441 KB
- Stars: 63
- Watchers: 2
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - StickyRecyclerSettingView - 快速在Android上建立SettingActivity (RecyclerView)
README
# StickyRecyclerSettingView
Effect
--------![](https://github.com/LinLshare/StickyRecyclerSettingView/blob/master/img/effect.gif?raw=true)
Use
--------At first, clone the project and run the demo;
Secondly, copy the code to your project and modify it to adapt your business.Here are the common way to setup setting view:
#### 1. New a SettingRecyclerAdapter
```java
SettingRecyclerAdapter settingRecyclerAdapter= new SettingRecyclerAdapter();
```#### 2. Define Settings.xml
like this: [settings.xml](https://github.com/LinLshare/StickyRecyclerSettingView/blob/master/app/src/main/res/xml/settings.xml)
```xml
...```
#### 3. Parse xml file and add data to adapter
use XmlResourceParser to parse the xml file you defined before(like this: [SettingActivity#loadData](https://github.com/LinLshare/StickyRecyclerSettingView/blob/master/app/src/main/java/io/github/linlshare/settingstickyrecyclerview/SettingActivity.java#L54)), and then call `settingRecyclerAdapter.addAll(settingItemList);` to add them to adapter.
#### 4. SetItemClickListener
Just call `settingRecyclerAdapter.setOnItemClickListener(this);` and then handle the event like follow:
```java
@Override public void onItemClick(int id, SettingItem item) {
Util.toast(this, item);
if (id == R.id.name) {
settingRecyclerAdapter.updateSecondaryText(id, "Here it go");
}
}
```
#### 5. RecyclerView Setup```java
recyclerView.setLayoutManager(
new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(settingRecyclerAdapter);
recyclerView.addItemDecoration(new PinnedHeaderItemDecoration());
```Thanks To
--------- AdapterDelegates: https://github.com/sockeqwe/AdapterDelegates
- pinned-section-item-decoration: https://github.com/takahr/pinned-section-item-decoration
License
--------Copyright 2016 Lshare
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.