Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JakeWharton/kotterknife
View "injection" library for Android.
https://github.com/JakeWharton/kotterknife
Last synced: 3 months ago
JSON representation
View "injection" library for Android.
- Host: GitHub
- URL: https://github.com/JakeWharton/kotterknife
- Owner: JakeWharton
- License: apache-2.0
- Archived: true
- Created: 2014-10-20T06:05:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-12T16:12:45.000Z (about 5 years ago)
- Last Synced: 2024-05-09T09:12:11.847Z (6 months ago)
- Language: Kotlin
- Homepage:
- Size: 600 KB
- Stars: 2,225
- Watchers: 66
- Forks: 199
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-android - Kotterknife - Android view injection written in Kotlin based on ButterKnife (Development Alternatives / Kotlin)
- awesome-kotlin - kotterknife - View binding made easy. (Libraries / Android)
- awesome-kotlin - Kotter Knife - View "injection" library for Android. (Libraries)
- awesome-android-libraries - kotterknife
- awesome-kotlin-cn - Kotter Knife - View "injection" library for Android (开源库和框架 / 依赖注入)
- awesome-android - Kotterknife - Android view injection written in Kotlin based on ButterKnife (Development Alternatives / Kotlin)
- awesome-android-cn - 官网
- awesome-kotlin-android - Kotter Knife - View "injection" library for Android. (Libraries)
- trackawesomelist - JakeWharton/kotterknife (⭐2.2k)
- awesome-kotlin-libraries-for-android - KotterKnife - View injection library for Android. (<a name="dependency-injection"></a>Dependency Injection <sup>[Back ⇈](#contents)</sup>)
- awesome-kotlin-android - kotterknife - 基于ButterKnife 使用 kotlin编写的 Android 依赖注入框架 🔥🔥🔥🔥🔥 (开源库 / 依赖注入)
README
Kotter Knife
============**Deprecated**: This was a terrible idea because it allocates an object for every view reference.
Do not use, and do not use anything like it.
Use [view binding](https://developer.android.com/topic/libraries/view-binding) instead.![](art/logo.png)
[Butter Knife][1]-esque view binding for Kotlin.
```kotlin
public class PersonView(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
val firstName: TextView by bindView(R.id.first_name)
val lastName: TextView by bindView(R.id.last_name)// Optional binding.
val details: TextView? by bindOptionalView(R.id.details)// List binding.
val nameViews: List by bindViews(R.id.first_name, R.id.last_name)// List binding with optional items being omitted.
val nameViews: List by bindOptionalViews(R.id.first_name, R.id.middle_name, R.id.last_name)
}
```These methods are available on subclasses of `Activity`, `Dialog`, `ViewGroup`, `Fragment`,
the support library `Fragment`, and recycler view's `ViewHolder`.Download
--------Currently not available via Maven Central.
A SNAPSHOT is available in the Sonatype snapshot repo.
```groovy
compile 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT'
```You can also copy `ButterKnife.kt` into your source tree. The file depends on the 'support-v4' and
'recyclerview-v7' libraries but the dependency is easily removed by deleting a few lines.Comments, suggestions, and pull requests are encouraged!
License
-------Copyright 2014 Jake Wharton
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.[1]: http://jakewharton.github.io/butterknife