Butterknife butter knife

[function] (1) binding field

(2) you can bind components or arrays of groups

(3) binding listener

(4) bind resources (pictures, strings, arrays) (@ bindbool, @ bindcolor, @ binddimension, @ binddrawable, @ bindint, @ bindstring)

---------------- for more information, please visit the official website

(set the URL loaded by the butterknife plug-in)

  implementation 'com.jakewharton:butterknife:8.8.1'

  annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

You can also search to join by

[project structure]

  【strings.xml】

  【activity_main.xml】

  【MainActivity.java】

[effect]

[project structure]

  【fragment_fancy.xml】

  【FancyFragment.java】

[note] butterknife. Bind (this, view) is used; Different from activity

[effect] paste the fragment on the activity to achieve the final effect

[project structure]

  【item.xml】

  【MyHolder.java】

  【MyAdapter.java】

[note] to create myholder, you need to pass in the view parameter. The recycleview used here is a little different from the baseadapter of listview, but the used one will be well understood.

[final effect]

For example, multiple textviews are bound together into a list collection.

The annotation used is @ bindviews ({x, y, Z}) - > List < View >

  【activity_main.xml】

  【MainActivity.java】 

[effect]

[core code]

  【activity_main.xml】

[mainactivity. Java] remains unchanged.

[effect]

The purpose is to make the program performance better and release the binding when not in use.

[case] implement binding reset in fragment

[project structure]

  【fragment_red.xml】

  【fragment_blue.xml】

  【RedFragment.java】

  【BlueFragment.java】

[final effect]

[note] be sure to right-click the cursor and mouse on the layout, otherwise it will be invalid

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>