package tdc.edu.vn.baitap; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button btnBai2,btnBai4,btnThoat; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setControl(); setEvent(); } private void setEvent() { btnBai2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent (MainActivity.this, bai2.class); startActivity(intent); } }); btnBai4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent (MainActivity.this, bai4.class); startActivity(intent); } }); btnThoat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), MainActivity.class); startActivity(intent); Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startActivity(startMain); finish(); } }); } private void setControl() { btnBai2 = findViewById(R.id.btnBai2); btnBai4 = findViewById(R.id.btnBai4); btnThoat = findViewById(R.id.btnThoat); } }