Initial use of ButterKnife

ButterKnief (butter knife) use

ButterKnife is a View injection framework that focuses on the Android system. In the past, you always have to write a lot of findViewById to find the View object. With ButterKnife, these steps can be easily omitted. Using ButterKnife basically has no performance loss, because the annotations used by ButterKnife are not reflected at runtime, but generate new classes at compile time

package com.example.talk;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;

import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.talk.utils.StatusTextColor;
import com.jaeger.library.StatusBarUtil;

import org.w3c.dom.Text;

import butterknife.BindView;
import butterknife.ButterKnife;
/*ButterKnife黄油刀框架*/
/*Usage in Activity*/
/*ButterKnife.bind(this)必须在初始化绑定布局文件(setContentView())之后,否则会报错*/
/*Usage in Fragment*/
/*和Activity相比在fragment destory时要将实例化的ButterKnife对象解绑,binder.unbind()*/
public class MainActivity extends AppCompatActivity {
    
    
    @BindView(R.id.tB_main)
    Toolbar mTb_main;
    @BindView(R2.id.vP_main)
    ViewPager mVp_main;
    @BindView(R2.id.ll_bot)
    LinearLayout mLl_bot;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
    
        super.onCreate(savedInstanceState);
        StatusBarUtil.setTranslucent(this);
        setContentView(R.layout.activity_main);
        StatusTextColor.Drak(this);
        ButterKnife.bind(MainActivity.this);

    }
}

Guess you like

Origin blog.csdn.net/xu331700/article/details/113064385