{"id":36420577,"url":"https://github.com/zeoflow/view-binding","last_synced_at":"2026-01-11T17:33:02.847Z","repository":{"id":53001792,"uuid":"290177404","full_name":"zeoflow/view-binding","owner":"zeoflow","description":"A lightweight library aiming to speed up Android app development by leveraging the new Android Data Binding together with the Model-View-ViewModel design pattern.","archived":false,"fork":false,"pushed_at":"2021-04-10T08:59:09.000Z","size":366,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-20T20:07:22.223Z","etag":null,"topics":["android-library","data-binding","lifecycle","view-binding","viewmodel","zeoflow","zeoflow-library"],"latest_commit_sha":null,"homepage":"https://zeoflow.github.io/view-binding/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeoflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-25T09:52:04.000Z","updated_at":"2024-05-20T20:07:22.224Z","dependencies_parsed_at":"2022-09-08T00:21:21.895Z","dependency_job_id":null,"html_url":"https://github.com/zeoflow/view-binding","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zeoflow/view-binding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeoflow%2Fview-binding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeoflow%2Fview-binding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeoflow%2Fview-binding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeoflow%2Fview-binding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeoflow","download_url":"https://codeload.github.com/zeoflow/view-binding/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeoflow%2Fview-binding/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28315879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-library","data-binding","lifecycle","view-binding","viewmodel","zeoflow","zeoflow-library"],"created_at":"2026-01-11T17:33:02.237Z","updated_at":"2026-01-11T17:33:02.841Z","avatar_url":"https://github.com/zeoflow.png","language":"Java","readme":"# View Binding\n\n## Intro\nA lightweight library aiming to speed up Android app development by leveraging the new [Android Data Binding](http://developer.android.com/tools/data-binding/guide.html) and taking the best from the [Model-View-ViewModel](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel) design pattern.\n\n## Getting Started\nFor information on how to get started with View Binding,\ntake a look at our [Getting Started](docs/getting-started.md) guide.\n\n## Submitting Bugs or Feature Requests\nBugs or feature requests should be submitted at our [GitHub Issues section](https://github.com/zeoflow/view-binding/issues).\n\n\n## Why should I use it?\n1. **Data Binding**\n Android Data Binding is great and if you're not, you should start using it today.\n2. **You don't need to care about screen rotation (configuration change) at all.**\n Most of the screen lifecycle is moved to ViewModel where the lifecycle is dramatically easier to understand and to use. The **ViewModel instance outlives it's Activity/Fragment** during configuration change so no more hassle with `onSaveInstanceState()` or using retained Fragments.\n3. **ViewModel as the only variable in the layout**\n ViewModel serves as the data provider in layout's binding as well as handler for click or other methods common fro Data Binding. With a construct like `android:onClick=\"@{viewBinding.onClickedPlayButton}\"` **you will never have to set an `OnClickListener` anymore**. Also, each ViewModel extends `BaseObservable` so you have a choice between using BaseObservable approach or ObservableField approach within the DataBinding. (see [Data Binding Guide](http://developer.android.com/tools/data-binding/guide.html))\n\n## How does it work?\nThe framework extensively uses Java Generics to provide a type-safe link between Activity/Fragment and ViewModel and its binding.\n\nViewModel instances are stored in a global static Map and reattached automatically to corresponding Activity/Fragment. When there is no need for the ViewModel anymore (Activity finished) the instance is destroyed.\n\n### 1. Depend on our library\n\nView Binding for Android is available through Google's Maven Repository.\nTo use it:\n\n1.  Open the `build.gradle` file for your application.\n2.  Make sure that the `repositories` section includes Google's Maven Repository\n    `google()`. For example:\n\n    ```groovy\n      allprojects {\n        repositories {\n          google()\n          jcenter()\n        }\n      }\n    ```\n\n3.  Add the library to the `dependencies` section:\n\n    ```groovy\n      dependencies {\n        // ...\n        implementation 'com.zeoflow:view-binding:\u003cversion\u003e'\n        // ...\n      }\n    ```\n\n### 2. Activity/Fragment Class\n`MainActivity.java`\n\n```java\npublic class MainActivity extends BindAppActivity\u003cActivityMainBinding, MainViewBinding\u003e\n{\n    //..\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState)\n    {\n        //..\n        setupViewBinding(R.layout.activity_main, MainViewBinding.class);\n        //..\n        super.onCreate(savedInstanceState);\n        //..\n        MainViewBinding mMainViewBinding = getViewBinding();\n        //..\n    }\n    //..\n}\n```\n\n### 3. Activity/Fragment Layout\n`activity_main.xml`\n\n```xml\n\u003clayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\txmlns:tools=\"http://schemas.android.com/tools\" xmlns:app=\"http://schemas.android.com/apk/res-auto\"\u003e\n\n\t\u003cdata\u003e\n\n        \u003cvariable\n            name=\"viewBinding\"\n            type=\"com.zeoflow.view.binding.sample.MainViewBinding\" /\u003e\n\t\u003c/data\u003e\n\n\t\u003cLinearLayout\n\t\tandroid:layout_width=\"match_parent\"\n\t\tandroid:layout_height=\"match_parent\"\n\t\tandroid:padding=\"@dimen/activity_padding\"\n\t\tandroid:orientation=\"vertical\"\u003e\n\n\t\t\u003candroid.support.design.widget.TextInputLayout\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"wrap_content\"\u003e\n\n\t\t\t\u003cEditText\n\t\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\t\tandroid:text=\"@={viewBinding.name}\"\n\t\t\t\tandroid:inputType=\"textPersonName|textCapWords\"\n\t\t\t\tandroid:hint=\"@string/hint_enter_your_name\" /\u003e\n\t\t\u003c/android.support.design.widget.TextInputLayout\u003e\n\n\n\t\t\u003cFrameLayout\n\t\t\tandroid:layout_width=\"match_parent\"\n\t\t\tandroid:layout_height=\"0dp\"\n\t\t\tandroid:layout_weight=\"1\"\n\t\t\tandroid:animateLayoutChanges=\"true\"\u003e\n\n\t\t\t\u003cTextView\n\t\t\t\tandroid:layout_width=\"wrap_content\"\n\t\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\t\tandroid:layout_gravity=\"center\"\n\t\t\t\tandroid:textAppearance=\"@style/Base.TextAppearance.AppCompat.Headline\"\n\t\t\t\tandroid:textColor=\"@color/colorPrimary\"\n\t\t\t\tandroid:text=\"@{@string/hello(viewBinding.name)}\"\n\t\t\t\tapp:show=\"@{viewBinding.name != null \u0026amp;\u0026amp; !viewBinding.name.empty}\"\n\t\t\t\ttools:text=\"@string/hello\" /\u003e\n\t\t\u003c/FrameLayout\u003e\n\n\n\t\t\u003cButton\n\t\t\tandroid:layout_width=\"wrap_content\"\n\t\t\tandroid:layout_height=\"wrap_content\"\n\t\t\tandroid:layout_gravity=\"center\"\n\t\t\tandroid:onClick=\"@{() -\u003e viewBinding.showDialog()}\"\n\t\t\tandroid:text=\"@string/button_dialog_fragment\"\n\t\t\tstyle=\"@style/Widget.AppCompat.Button.Colored\" /\u003e\n\t\u003c/LinearLayout\u003e\n\u003c/layout\u003e\n\n```\n\n### 4. ViewModel\n`MainViewModel.java`\n\n```java\npublic class MainViewBinding extends ViewBinding\n{\n\n\tpublic final ObservableField\u003cString\u003e name = new ObservableField\u003c\u003e();\n\n\t@Override\n\tpublic void onViewModelCreated()\n\t{\n\t\tsuper.onViewModelCreated();\n\t\t// Do API calls etc.\n\t}\n\n\t@Override\n\tpublic void onViewAttached(boolean firstAttachment)\n\t{\n\t\tsuper.onViewAttached(firstAttachment);\n\t\t// manipulate with the view\n\t}\n}\n```\n\n## License\n    Copyright 2020 ZeoFlow\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n      http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeoflow%2Fview-binding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeoflow%2Fview-binding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeoflow%2Fview-binding/lists"}