Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

kotterknife

View "injection" library for Android.

Subscribe to updates I use kotterknife


Statistics on kotterknife

Number of watchers on Github 1908
Number of open issues 20
Average time to close an issue 5 days
Main language Kotlin
Average time to merge a PR 1 day
Open pull requests 16+
Closed pull requests 8+
Last commit almost 2 years ago
Repo Created almost 5 years ago
Repo Last Updated over 1 year ago
Size 612 KB
Organization / Authorjakewharton
Contributors8
Page Updated
Do you use kotterknife? Leave a review!
View open issues (20)
View kotterknife activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating kotterknife for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Kotter Knife

Butter Knife-esque view binding for 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<TextView> by bindViews(R.id.first_name, R.id.last_name)

  // List binding with optional items being omitted.
  val nameViews: List<TextView> 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.

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 at

   http://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.
kotterknife open issues Ask a question     (View All Issues)
  • about 3 years Bind view in arbitrary class
  • over 3 years How to bind DialogFragment
  • over 4 years Support ViewHolder pattern
  • over 4 years Bind view in retained Fragment
kotterknife open pull requests (View All Pulls)
  • Added Butterknife.reset() for reseting cached views
  • Made the how-to more plug-and-play
  • Added Any-extensions for view-binding
  • added @OnClick replacement
  • Binding with source
  • Reset cached bindings
  • Bindings to custom container based on ViewContainer
  • Upgrade kotlin, android plugin, android build tools and android support ...
  • Bind on custom classes via new interface
  • Add support for binding views on DialogFragments
  • Code cleanup, updates
  • added support for binding views in dialog preferences
  • Support binding from custom classes
  • Add variance information to custom Lazy implementation
  • Rename unused parameters to `_`
  • Update dependencies and fix broken Travis build
kotterknife questions on Stackoverflow (View All Questions)
  • KotterKnife - cannot use bindView(R.id.example_id) for some classes
kotterknife list of languages used
Other projects in Kotlin