ButterKnife與BindView使用詳解

2021-08-30 11:08:44 字數 1390 閱讀 8052

在activity中butterknife.bind(this);必須在setcontentview();之後,且父類bind繫結後,子類不需要再bind

在fragment中butterknife.bind(this, view);

在adapter中butterknife.bind(this, view);

屬性布局不能使用private、static修飾

dependencies
dependencies )

testcompile 'junit:junit:4.12'

// implementation 'com.jakewharton:butterknife:8.5.1'

// annotationprocessor 'com.jakewharton:butterknife-compiler:8.5.1'

}

@bindview---->繫結乙個view;id為乙個view 變數

@bindview(r.id.tv_fm1)

textview tvfm1;

@bindviews ---->繫結多個view;id為乙個view的list變數

@bindviews()

list buttons;

@bindarray---->繫結string裡面array陣列;

@bindarray(r.array.city )

string citys ;

@bindbitmap---->繫結資源為bitmap;

@bindbitmap(r.mipmap.wifi )

bitmap bitmap;

@bindbool ---->繫結boolean值

@bindcolor ---->繫結color;

@bindcolor(r.color.coloraccent)

int black;

@binddimen ---->繫結dimen;

@binddimen(r.dimen.borth_width)

int mborderwidth;

@binddrawable ----> 繫結drawable;

@binddrawable(r.drawable.test_pic)

drawable mtestpic;

@bindfloat ---->繫結float

@bindint ---->繫結int

class exampleactivity extends activity 

}

上面**相當於:

public void bind(exampleactivity activity)

ButterKnife與BindView使用詳解

butterknife與bindview使用詳解 butterknife的優勢 使用方法以及注意事項 在activity中butterknife.bind this 必須在setcontentview 之後,且父類bind繫結後,子類不需要再bind 在fragment中butterknife.bi...

ButterKnife 新增使用

在使用 butterknife的時候 只配置乙個地方是不行的 之前一直只設定乙個,解析控制項有問題後來才知道,還需要把其他部分的配置補齊才能正確的解析控制項 compile com.jakewharton butterknife 8.6.0 apt com.jakewharton butterkni...

ELF與BIN檔案區別

gcc 編譯出來的是elf檔案。通常gcc o test test.c,生成的test檔案就是elf格式的,在linuxshell下輸入 test就可以執行。bin 檔案是經過壓縮的可執行檔案,去掉elf格式的東西。是直接的記憶體映像的表示。在系統沒有載入作業系統的時候可以執行。elf execut...