Skip to content

use kotlin delegated properties and easily delegate your viewbinding classes. One of the advantages of this library is the reduction of your code.

Notifications You must be signed in to change notification settings

AliAzizi/Android-ViewBindingDelegatedProperty-kotlin

Repository files navigation

Android Viewbinding delegated property

With this library you can use the power of kotlin delegated properties and easily delegate your viewbinding classes. One of the advantages of this library is the reduction of your code. 😍😍

alt text

installation (Gradle)

Add this line in your build.gradle file :

android {
    ...
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    ...
    implementation 'com.github.A-Azizi79:Android-ViewBindingDelegatedProperty-kotlin:0.1.0'
}

Usage

// You must replace YourActivityBinding with your generated binding file name like ActivityMainBinding or ...
class YourActivity : AppCompatActivity() {
    val binding: YourActivityBinding by viewBinding(YourActivityBinding::inflate)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // you must remove setContentView(R.layout.name) because we will do that for you! Awsome right?
        //calling textView1 and set (Hello World!) text on it
        binding.textView1.text = "Hello world"
    }
}

Contact me

you can find me @here on Telegram messenger 😎

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License 🇮🇷

MIT

About

use kotlin delegated properties and easily delegate your viewbinding classes. One of the advantages of this library is the reduction of your code.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages