Sinh viên Nguyễn Anh Quân Báo cáo chỉ tiêt Báo cáo lập trình mobile trên android studio... - Gidi thiệu Tài liệu được viết dựa trên: e Android Studio 3.6.1 Mục tiêu của tài liệu
Trang 1
= DAl HOC DIEN LUC
ELECTRIC POWER UNIVERSITY
BAI TIEU LUAN HET HOC PHAN Môn: Phát Triển ứng dụng trên thiết bị di động
Họ và tên sinh viên: Vương Trường Giang Ma SV: 18810540102
Lớp: D13 ĐT&KTMT Nhóm: 7
Khoa: DTVT Chuyên ngành: ĐT&KTMT
Hà nội, ngày 6 tháng 8 năm 2020
Trang 2
Tén tiêu luận:
Ứng dụng máy tính cầm túi
Hà Nội, ngày 08 tháng 06 năm 2022
Sinh viên
Nguyễn Anh Quân
Báo cáo chỉ tiêt
Báo cáo lập trình mobile trên android studio
Trang 3- Gidi thiệu
Tài liệu được viết dựa trên:
e Android Studio 3.6.1
Mục tiêu của tài liệu hướng dẫn bạn làm quen với một vài kỹ thuật đơn giản trong lập trình Game 2D Android Bao gôm:
® Sử dụng SuffaceView
® Vẽ trên Canvas
e Chuyển động của các nhân vật game
® Tương tác với cử chỉ của người chơi
2- Tạo một Game Project
Trên Android Studio tao méi m6t project:
Trang 4re Select a Project Template
Phone and Tablet Wear OS TV Automotive Android Things
No Activity
Creates a new empty project
Previous ( xa ) Cancel Finist
Name: maytinhcamtay
Trang 5px Configure Your Project
ee
a i
Help me choose
|_| Use legacy android.support libraries (7
Previous
( a org.o7planning.android2dgame _ a :
¬=—-Z
Minimum SDK — API 16: Android 4.1 Jelly Bean) v
No Activity © Your app will run on approximately 99.8% of devices
ee
ere
OK, Project cui bạn đã được tao ra
Trang 6» OS manifests
mm
> P§ java (generated)
» Se res
» @ Gradle Scripts
Activity Name: MainActivity
Trang 7px Configure Activity
Creates a new empty activity
Activity Name: MainActivity
PO
\ (@ Launcher Activity
——
Package name: org.o7planning.android2dgame
Target Source Set: main
If true, this activity will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher
Z4 `
Chú ý rằng chúng đang tạo ra một Android, chính vì vậy giao diện của trò chơi phải do bạn vẽ ra, chính vì vậy chúng
ta không cân một file như la activity main.xml.
Trang 8_ java
org.o7planning.android2dgame
© MainActivity
org.o7/planning.android2dgame (androidTest)
org.o7planning.android2dgame (test)
res
drawable
mipmap
values
@ Gradle Scripts
Tiến hành viết code trén file activity main.xml B1: Tao TextView
<TextView
android:
android:
android:
android:
:textStyle="bold"
:Layout_marginTop ="36dp"
android:
:g"avity="right"/>
android
android
android
Layout_width="match_parent"
lLayout_height="wrap_content"
text="6"
textSize="40dp"
id="@+id/maytinh®
B2:Tao nut ,dat tên nút và cỡ chữ
Trang 9android: Layout_width="match_parent"
android: Layout_height="wrap_content"
android: orientation="horizontal">
<Button
android: Layout_width="wrap_content"
android: Layout_height="wrap_content"
android: onClick="del"
android: text="del"
android: textSize="30dp"
tools: ignore="UsingOnClickInxml" />
></LinearLayout>
B3:Khai bao cac chire nang hién thi, cac phép tinh
public class MainActivity extends AppCompatActivity {
private TextView hienthi;
String sa,sb;
char op = ‘'0';
@0verride
protected void onCreate(BundLe savedInstanceState) {
setContentView(R.Layout.activity_main);
sa = sb ="";
public void del(View view) {
$a Sep :So"*s
hienthi.setText("");
Trang 10double a = 0,b = 0,kq = 0;|
b = Double valuedf(sa) ;
Sa = sb ="";
switch (op){
case ‘+':
kg = a+b j;
break;
case '-':
kq = 8 ~
break;
case 'x':
kg = a *
break;
case '/':
kq=a/b;
break;
default: kq = 0;
}
public void pheptinh(View view) {
sb = sa;
sa ="";
Button tinh = (Button) view;
String tam2 = tinh.getText().toString();
op = tam2.charAt(0);
public void so(View view) {
Button tam = (Button) view;
sa += tam.getText().toString();
hienthi.setText(sa);
B4:Kiém tra và chạy chương trình
Trang 11máy tính1