XML layout

Add 'm' prefix to variable name. For example, 'mEdittextUserName'
Add typecasting for view. For example, '(TextView) findViewById(R.id.tv_name);'

Android View Binding (AVB) Code Generator

What is this?

Mother of this tool is a question, why should I write whole binding code in java activity when view IDs are already mentioned in XML file.
This is a tool for those android developers who don't want to waste time in writing binding code. :)

How to use

  1. Add ids to all XML views which are required in java code
  2. Copy XML layout file
  3. Paste the copied file text in "XML layout" area
  4. Now copy the generated code
  5. Paste that code to java activity / fragment / viewholde / ... accordingly
  6. Done!


Use in Activity

  • Make sure that output mode is set to Acitivities
  • After pasting generated code (How to use step 5), call bindViews() function after setContentView() in onCreate() method.

Use in Fragment / Viewholder etc..

  • Make sure that output mode is set to Fragments / ViewHolders / Others
  • After pasting generated code (How to use step 5), call bindViews() function when layout is populated.
    • Fragments: in function onViewCreated().
    • Viewholders: after super(view); call in constructor.

Use with ButterKnife

Butter Knife is a great and well known android library used for view injection.It is maintained by Jake Wharton. To integrate ButterKnife, check github guide.
  • Set output mode to ButterKnife
  • After pasting generated code (How to use step 5), call ButterKnife bind code when layout is populated. Make sure you are using ButterKnife library version >8.
  • Check Butter Knife guide for more details.

Use with ButterKnife in Library Module

  • Set output mode to ButterKnife Lib. Module
  • After pasting generated code (How to use step 5), call ButterKnife bind code when layout is populated.
  • This uses R2.id.tvTitle instead of R.id.tvTitle. Please check Butter Knife's library module guide for complete integration details.

Add 'm' prefix to variable name

  • Many developers follow naming convention with prefix 'm'.
  • Add / remove prefix using checkbox at the bottom of generated code block.

Note

  • Binder code will be generated for views which have declared .
  • View's variable name will be the camelCase of it's xml .
  • Can not generate binder code for views which are included using .
  • If anything goes wrong, please create an issue on Github repository. In issue, please add xml file's text for which tool did not work correctly.