package yifeiyuan.practice.practicedemos.customview; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import butterknife.ButterKnife; import butterknife.InjectView; import yifeiyuan.practice.practicedemos.R; public class SwitchActivity extends AppCompatActivity { @InjectView(R.id.toolbar) Toolbar mToolbar; @InjectView(R.id.face_view) FaceView mFaceView; @InjectView(R.id.fab) FloatingActionButton mFab; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_switch); ButterKnife.inject(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mFaceView.toogle(); // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); } }); } @Override protected void onResume() { super.onResume(); Log.d("MainActivity", " SwitchActivity onResume: "); } }