Tài liệu Tiếng Anh | Đại học Ngoại Ngữ - Tin Học thành phố Hồ Chí Minh
Tài liệu Tiếng Anh | Đại học Ngoại Ngữ - Tin Học thành phố Hồ Chí Minh được sưu tầm và soạn thảo dưới dạng file PDF để gửi tới các bạn sinh viên cùng tham khảo, ôn tập đầy đủ kiến thức, chuẩn bị cho các buổi học thật tốt. Mời bạn đọc đón xem
Môn: Tiếng Anh (basic english)
Trường: Đại học Ngoại ngữ - Tin học Thành phố Hồ Chí Minh
Thông tin:
Tác giả:
Preview text:
Bài 1 : Đổi độ C -> F và ngược lại Code XML:
<?xml version="1.0" encoding ?> ="utf-8"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android ="vertical" :orientation tools =".MainActivity" :context android:layout_margin="10dp" android:padding="5dp"> android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Farenheit"
android:textColor="@color/black" android:textSize="25dp" /> android:id="@+id/edtF"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:ems="10"
android:inputType="textPersonName"
android:layout_marginTop="10dp"/> android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Celsius"
android:textColor="@color/black" android:textSize="25dp" /> android:id="@+id/edtC"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:ems="10"
android:inputType="textPersonName"
android:layout_marginTop="10dp" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"> android:id="@+id/btnFC"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="Convert to Celsius" /> android:id="@+id/btnCF"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="Convert to Fahrenheit" /> android:id="@+id/btnClear"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Clear"
android:layout_marginTop="10dp"/> Code Java:
package edu.huflit.btonline_tuan1; import ;
android.support.v7.app.AppCompatActivity import android.os.Bundle; import android.text.Editable; import android.view.View; import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity { //View EditText edtF, edtC; Button btnCF, btnFC, ; btnClear @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // Ánh sạ ID
edtC = findViewById(R.id.edtC);
edtF = findViewById(R.id.edtF);
btnCF = findViewById(R.id.btnCF);
btnFC = findViewById(R.id.btnFC); //Xử lý click
btnCF.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View view) {
int doC = Integer.parseInt(edtC.getText().toString()); double doF = doC* + 1.8 32;
String text = doF + "Độ F"; edtF.setText(text); } });
btnFC.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View view) {
int doF = Integer.parseInt(edtF.getText().toString()); double doC = (doF-32)/1.8; edtC.setText(doC+ ""); } });
btnClear.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View view) { edtC.setText(""); edtF.setText(""); } }); } } Bài 2 : Tính BMI Code XML :
<?xml version="1.0" encoding ?> ="utf-8"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" > android:id="@+id/textView"
android:layout_width="match_parent" android:layout_height="62dp" android:background="#268112" android:gravity="center"
android:text="Chương trình tính chỉ số BMI"
android:textColor="@color/white" ="25dp" android:textSize android:textStyle="bold"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:id="@+id/textView2" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" ="Nhập tên : " android:text android:textSize="18dp"/> android:id="@+id/edtTen" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" android:ems="10"
android:inputType="textPersonName" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:id="@+id/textView3" ="93dp" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" ="Chiều cao : " android:text android:textSize="18dp"/> android:id="@+id/edtChieuCao" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" android:ems="10"
android:inputType="textPersonName" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:id="@+id/textView4" ="93dp" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" ="Cân nặng : " android:text android:textSize="18dp"/> android:id="@+id/edtCanNang" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" android:ems="10"
android:inputType="textPersonName" /> android:id="@+id/btnKetQua"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Tính BMI" android:textColor="#FF0000" android:background="#8C8C8C" android:gravity="center" ="30dp" android:textSize android:textStyle="bold" /> android:id="@+id/btnXoa"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Xoá" android:textColor="#FF0000" android:background="#8C8C8C" android:gravity="center" ="30dp" android:textSize android:textStyle="bold"
android:layout_marginTop="10dp"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"> android:id="@+id/textView6" ="98dp" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" ="BMI = " android:text android:textSize="18dp"/> android:id="@+id/tvBMI" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" android:ems="10"
android:inputType="textPersonName" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp"> android:id="@+id/textView7" ="99dp" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" ="Chuẩn đoán : " android:text android:textSize="18dp"/> android:id="@+id/tvChuanDoan" ="wrap_content" android:layout_width
android:layout_height="wrap_content" android:layout_weight="1" android:ems="10"
android:inputType="textPersonName" /> Code Java: package edu.huflit.ex2; import ;
android.support.v7.app.AppCompatActivity import android.os.Bundle; import android.view.View; import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText edtTen, edtCanNang, edtChieuCao; Button btnKetQua, btnXoa; TextView tvBMI, tvChuanDoan; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtTen = findViewById(R.id.edtTen);
edtCanNang = findViewById(R.id.edtCanNang);
edtChieuCao = findViewById(R.id.edtChieuCao);
btnKetQua = findViewById(R.id.btnKetQua);
tvBMI = findViewById(R.id.tvBMI);
tvChuanDoan = findViewById(R.id.tvChuanDoan);
btnXoa = findViewById(R.id.btnXoa); btnKetQua new .setOnClickListener( View.OnClickListener() { @Override public void onClick(View v) { double cannang =
Double.parseDouble(edtCanNang.getText().toString()); double chieucao =
Double.parseDouble(edtChieuCao.getText().toString()); ;
Double BMI = cannang / (chieucao * chieucao)
// Xử lý BMI để làm tròn nó
BMI = (double) Math.round(BMI*100)/100;
tvBMI.setText(tvBMI.getText()+ BMI.toString()); //Xử lý thông số BMI
if(BMI < 18) tvChuanDoan.setText("Người gấy");
else if (BMI <= 24.9 && BMI >= 18) tvChuanDoan.setText("Người bình thường");
else if (BMI <= 29.9 && BMI >= 25) tvChuanDoan.setText("Người béo phì độ I");
else if (BMI <= 34.9 && BMI >= 30) tvChuanDoan.setText("Người béo phì cấp độ II");
else if (BMI > 35) tvChuanDoan.setText("Người béo phì cấp độ III"); } });
btnXoa.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { edtCanNang.setText(""); edtChieuCao.setText(""); tvBMI.setText(""); tvChuanDoan.setText(""); } }); } } Bài 3 : ListView Code XML:
<?xml version="1.0" encoding ?> ="utf-8"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android ="vertical" :orientation tools =".MainActivity" :context android:padding="5dp"> android:id="@+id/lvDiaDanh"
android:layout_width="match_parent"
android:layout_height="256dp" /> android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:srcCompat="@tools:sample/avatars" />
android:id="@+id/edtTenDiaDanh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" android:ems="10"
android:hint="nhập tên địa danh"
android:inputType="textPersonName" />
android:layout_width="match_parent" android:layout_height="44dp"
android:orientation="horizontal"> android:id="@+id/btnThemAnh"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1" android:text="Ảnh..." /> android:id="@+id/btnThem"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1" android:text="Thêm" /> Code Java: package edu.huflit.ex3; import ;
androidx.appcompat.app.AppCompatActivity import android.os.Bundle; import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton; import ; android.widget.ImageView
import android.widget.ListView; import android.widget.Toast; import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
Button btnThemAnh, btnThemDiaDanh; EditText edtTenDiaDanh; ImageView img; ListView ; listView ArrayList arrayList; ArrayAdapter ; arrayAdapter