بهترین پروژه های اندروید برای دانشجویان علوم کامپیوتر
بهترین پروژه های اندروید برای دانشجویان علوم کامپیوتر :: اندروید یک سیستم عامل اوپن سورس بر پایه لینوکس است برای دستگاه هایی مانند تلفن های هوشمند و یا تبلت ها. هرچند که امروزه بسیاری از دستگاه های دیگر نیز از اندروید برای هوشمند تر شدن استفاده میکنند مانند تلوزیون هوشمند، رابط هوشمند خودرو، لوازم برقی و … . از این نرم افزار برای اولین بار در سال ۲۰۰۷ پرده برداری شد و در سپتامبر ۲۰۰۸ اولین دستگاه اندروید لانچ شد. از آن زمان، گوگل که اسپانسر اندروید است تقریبا هر سال آپدیت ها و نسخه های جدید اندروید را منتشر میکند.
برخی از ویژگی هایی که اندروید ارائه میدهد:
- NFC – ان اف سی (Near Field Communications) امکان اتصال و تعامل دستگاه های الکترونیکی در فاصله های کوتاه
- UI زیبا و Intractive
- حافظه – SQLite یک دیتابیس سبک رابطه ای است که برای ذخیره سازی اطلاعات در سیستم عامل اندروید بکار میکرود
- پشتیبانی از چندین زبان و Direction
پیشنهاد شگفت انگیز کدفرند، دسترسی به تمامی دوره های آموزشی کدفرند تنها با ۹۹ هزار تومان
مسیر ساخت پروژه های اندروید
اولین و مهم ترین قدم یادگیری ابزارهای توسعه اندروید است. اما قبل از آن هم پیشنهاد میکنم یکی از زبان های برنامه نویسی اندروید یعنی Java و Kotlin و XML را در حداقل سطح مقدماتی یاد بگیرید. ابزار Android Studio از این زبان ها برای ساخت پروژه های اندروید استفاده میکند. دوره های آموزشی کامل و قدرتمندی برای یادگیری تمام این زبان ها در وبسایت کدفرند موجود هستند که میتوانید با تهیه یکی از پلن های اشتراک ویژه کدفرند به تمام این دوره ها دسترسی داشته باشید. دوره آموزش کاتلین (Kotlin) کامل و دوره جامع آموزش جاوا (صفر تا صد) کامل از جمله این آموزشها هستند. نهایتا انگیزه خودتان را حفظ کنید و دست از تلاش و تمرین بر ندارید تا پروژه شما بخوبی کار کند.
کاتلین یا جاوا : کدام زبان زا انتخاب کنیم؟
پروژه های اندروید سطح مبتدی
حال میخواهیم به بررسی برخی از پروژه های اندروید ساده و سطح مبتدی بپردازیم.
صفحه لاگین
تقریبا تمام اپلیکیشن های اندروید از کاربر درخواست ثبت نام و ارائه اطلاعات شخصی مثل نام، username، ایمیل، شماره تلفن و password میکنند تا کاربر بتواند هنگام لاگین های بعدی، از این اطلاعات استفاده کند. این یکی از ساده ترین و پایه ای ترین پروژه های اندروید برای انجام میباشد از آنجایی که در هر نوع اپلیکیشن که قصد توسعه آن را دارید، به یک صفحه لاگین نیاز خواهید داشت. برای مثال اپلیکیشن هایی با عناوینی مانند سلامتی، غذا، داروخانه، فروشگاه، شبکه های اجتماعی و بازی ها از شما میخواهند یک حساب کاربری ایجاد کنید تا اطلاعات خود را ذخیره کنید و کارتان را در برنامه از آخرین Session خود ادامه دهید. دوره آموزش برنامه نویسی اندروید (کامل)
فایل XML:
فایل xml صفحه لاگین شامل یک activity page کاربر پسند است که فیلدهای edit text را جهت دریافت اطلاعات مورد نیاز از کاربر نمایش میدهد. همچنین دارای یک دکمه لاگین و دو text قابل کلیک برای بازیابی پسورد و ساخت اکانت برای کاربران چدید است.
فایل جاوا:
فایل جاوا این صفحه لاگین input ها را از کاربر دریافت کرده و پس از اعتبار سنجی آنها، اطلاعات را در دیتابیس لوکال ذخیره کرده و کاربر را وارد اپلیکیشن میکند.
نمونه کد:
فایل XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 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" android:id="@+id/content" tools:context=".MainActivity"> <!--<TextView--> <!--android:layout_width="wrap_content"--> <!--android:layout_height="wrap_content"--> <!--android:text="Login Page"--> <!--android:textSize="52dp"--> <!--android:textColor="#FFF"--> <!--android:textAlignment="center"--> <!--android:background="#03A9F4"--> <!--android:layout_marginRight="30dp"--> <!--android:layout_marginLeft="70dp"--> <!--android:layout_marginTop="30dp"--> <!--android:textStyle="bold"/>--> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/hackr" android:layout_marginTop="50dp"/> <android.support.design.widget.TextInputLayout android:id="@+id/et_username" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:layout_marginTop="70dp" app:boxStrokeColor="#223CD6" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <android.support.design.widget.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter Username" android:inputType="text" android:maxLines="1"/> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/et_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:layout_marginTop="20dp" app:boxStrokeColor="#223CD6" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <android.support.design.widget.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter Password" android:inputType="text" android:maxLines="1"/> </android.support.design.widget.TextInputLayout> <Button android:id="@+id/login_button" android:layout_width="189dp" android:backgroundTintMode="multiply" android:layout_height="wrap_content" android:layout_marginLeft="120dp" android:layout_marginRight="120dp" android:layout_marginTop="30dp" android:backgroundTint="#03A9F4" android:text="Login" android:textColor="#FFFFFF" android:textSize="28dp" /> <TextView android:id="@+id/create" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="120dp" android:layout_marginRight="120dp" android:textAlignment="center" android:layout_marginTop="20dp" android:textSize="18dp" android:textStyle="bold" android:textColor="#03A9F4" android:text="Create Account"/> <TextView android:id="@+id/change_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="120dp" android:layout_marginRight="120dp" android:textAlignment="center" android:layout_marginTop="20dp" android:textSize="18dp" android:textStyle="bold" android:textColor="#03A9F4" android:text="Change Password" /> </LinearLayout>
فایل Java
package com.skarora.loginpage; import android.content.Intent; import android.database.Cursor; import android.support.design.widget.TextInputLayout; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { TextInputLayout username,password; TextView create,change_pass; Button login; LoginData ld; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().hide(); username = findViewById(R.id.et_username); password = findViewById(R.id.et_password); login = findViewById(R.id.login_button); create = findViewById(R.id.create); change_pass = findViewById(R.id.change_password); ld=new LoginData(this); createUser(); loginUser(); changePassword(); } public void loginUser(){ login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = username.getEditText().getText().toString(); String pass = password.getEditText().getText().toString(); showMessage("Name",name); showMessage("Pass", pass); Cursor loginStatus= ld.validate(name,pass); if(name.equals("") || pass.equals("")) { showMessage(" ERROR!! ", "EMPTY FIELDS"); } else if(loginStatus.getCount()==0) { Toast.makeText(getApplicationContext(),"hello",Toast.LENGTH_LONG).show(); // showMessage("Login Successful" , "You have successfully logged in :) "); Intent in = new Intent(getApplicationContext(),Home.class); startActivity(in); } else { Toast.makeText(getApplicationContext(),"hiii",Toast.LENGTH_LONG).show(); showMessage("ERRR...", "TRY AGAIN!!!!!"); } } }); } public void createUser() { create.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(),Create_Acc.class); startActivity(i); } }); } public void changePassword() { change_pass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(),ChangePass.class); startActivity(i); } }); } public void showMessage(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setTitle(title); builder.setMessage(message); builder.show(); } }
پیشنهاد شگفت انگیز کدفرند، دسترسی به تمامی دوره های آموزشی کدفرند تنها با ۹۹ هزار تومان
اپلیکیشن ماشین حساب ساده (Calculator)
پروژه ماشین حساب نیز یک اپلیکیشن خوب برای شرو ع به توسعه پروژه های اندروید میباشد چراکه در تمامی تلفن ها و تبلت ها موجود است. این برنامه به شما کمک میکند طرح های مختلف مورد نیاز برای طراحی اپلیکیشن در فرانت اند را یاد بگیرید. نمونه زیر یک اپ بسیار ساده میسازد که در آن کاربر دو عدد را در دو text input جداگانه وارد میکند و عملیات مورد نظرش را با کلیگ روی دکمه های موجود انتخاب میکند و نتیجه عملیات را مشاهده میکند. با کلیک روی دکمه reset، مقادیر تمام فیلدها خالی شده و نتیجه عملیات نیز پاک میشود و کاربر میتواند دوباره مقادیر جدید را وارد کند. دوره آموزش برنامه نویسی اندروید (کامل)
فایل XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 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" tools:context=".MainActivity" android:orientation="vertical" android:background="#FFF"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_marginBottom="30dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:background="#FFF"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Basic Calculator" android:textAlignment="center" android:textColor="#000" android:textSize="30dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:background="#FFF" android:layout_gravity="center"> <EditText android:id="@+id/firstVal" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:hint="Enter First Number" android:textColorHint="#03A9F4" android:textAlignment="center" android:textSize="20dp" android:textColor="#000" android:inputType="numberDecimal" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="50dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:background="#FFF" android:layout_gravity="center"> <EditText android:id="@+id/secondVal" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:hint="Enter Second Number" android:textColorHint="#03A9F4" android:textAlignment="center" android:textSize="20dp" android:textColor="#000" android:inputType="numberDecimal" android:layout_marginLeft="30dp" android:layout_marginRight="30dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="30dp" android:layout_marginLeft="0dp" android:layout_marginTop="20dp" android:layout_marginRight="0dp" android:background="#FFF" android:layout_gravity="center" > <Button android:id="@+id/add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:background="#03A9F4" android:onClick="add" android:text="+" android:textSize="15dp" /> <Button android:id="@+id/sub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="#03A9F4" android:onClick="add" android:text="-" android:textSize="15dp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="#03A9F4" android:onClick="add" android:text="/" android:textSize="15dp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="#03A9F4" android:onClick="add" android:text="*" android:textSize="15dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="30dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:background="#FFF" android:layout_gravity="center"> <Button android:id="@+id/reset" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="60dp" android:layout_marginRight="60dp" android:textAlignment="center" android:layout_marginTop="30dp" android:background="#03A9F4" android:onClick="reset" android:text="Reset" android:textSize="30dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="0dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:layout_marginTop="10dp" android:background="#FFF" android:layout_gravity="center"> <TextView android:id="@+id/result" android:background="#03A9F4" android:layout_width="match_parent" android:layout_height="match_parent" android:hint="Result" android:textSize="30dp" android:layout_marginRight="20dp" android:layout_marginLeft="20dp" android:textColor="#FFF" android:textColorHint="#FFF" android:textAlignment="center" android:layout_marginTop="50dp"/> </LinearLayout> </LinearLayout>
فایل Java
package com.skarora.basiccalculator; 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 et1,et2; TextView t1,result; Button b1,b2,b3,b4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et1 = findViewById(R.id.firstVal); et2 = findViewById(R.id.secondVal); b1 = findViewById(R.id.add); b2 = findViewById(R.id.sub); b3 = findViewById(R.id.div); b4 = findViewById(R.id.times); result = findViewById(R.id.result); } public void add(View view) { String firstVal = et1.getText().toString(); String secondVal = et2.getText().toString(); double x = Double.parseDouble(firstVal); double y = Double.parseDouble(secondVal); result.setText(""+(x+y)); } public void sub(View view) { String firstVal = et1.getText().toString(); String secondVal = et2.getText().toString(); double x = Double.parseDouble(firstVal); double y = Double.parseDouble(secondVal); result.setText(""+(x-y)); } public void div(View view) { String firstVal = et1.getText().toString(); String secondVal = et2.getText().toString(); double x = Double.parseDouble(firstVal); double y = Double.parseDouble(secondVal); result.setText(""+(x/y)); } public void times(View view) { String firstVal = et1.getText().toString(); String secondVal = et2.getText().toString(); double x = Double.parseDouble(firstVal); double y = Double.parseDouble(secondVal); result.setText(""+(x*y)); } public void reset(View view) { String firstVal = et1.getText().toString(); String secondVal = et2.getText().toString(); et1.setText(null); et2.setText(null); } }
پروژه های اندروید سطح متوسط و پیشرفته
بازی Tic-Tac-Toe (پروژه سطح متوسط)
توسعه بازی ها در اندروید گام خوبی برای به تسلط یافتن روی این ابزار است و انجام پروژه های بازی اندرویدی همچنین فرصتهای خوبی را برای افرادی که به دنبال حرفه ای تر شدن در برنامه نویسی اندروید هستند باز میکند.
Tic-tac-toe یک بازی معروف و در عین حال بسیار ساده برای شروع به توسعه بازی اندروید میباشد. یک بازی دو نفره که هر بازیکن با علامت های “X” و “O” شناخته میشود. هر بازیکن باید در نوبت خود “X” یا “O” خود را در جدول موجود قرار دهد و سعی کند حرکت های بعدی رقیب را بلاک کند. دوره آموزش برنامه نویسی اندروید (کامل)
فایل XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 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" android:background="#03A9F4" tools:context=".MainActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/text_view_p1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Player 1: 0 " android:textSize="30sp" android:layout_marginLeft="10dp" android:layout_marginBottom="5dp"/> <TextView android:id="@+id/text_view_p2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text_view_p1" android:text="Player 2: 0" android:textSize="30sp" android:layout_marginLeft="10dp" /> <Button android:id="@+id/button_reset" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_marginEnd="33dp" android:text="reset" android:background="#FFF" android:layout_marginRight="33dp" android:layout_alignParentRight="true" /> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_marginBottom="5dp"> <Button android:id="@+id/button_00" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_01" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_02" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_marginBottom="5dp"> <Button android:id="@+id/button_10" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_11" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_12" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_marginBottom="5dp"> <Button android:id="@+id/button_20" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_21" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> <Button android:id="@+id/button_22" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:textSize="60sp" android:background="#B2EBF2" android:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp"/> </LinearLayout> </LinearLayout>
فایل Java
package com.skarora.tictactoe; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button[][] buttons = new Button[3][3]; private boolean player1Turn = true; private int roundCount; private int player1Points; private int player2Points; private TextView textViewPlayer1; private TextView textViewPlayer2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textViewPlayer1 = findViewById(R.id.text_view_p1); textViewPlayer2 = findViewById(R.id.text_view_p2); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { String buttonID = "button_" + i + j; int resID = getResources().getIdentifier(buttonID, "id", getPackageName()); buttons[i][j] = findViewById(resID); buttons[i][j].setOnClickListener(this); } } Button buttonReset = findViewById(R.id.button_reset); buttonReset.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { resetGame(); } }); } @Override public void onClick(View v) { if (!((Button) v).getText().toString().equals("")) { return; } if (player1Turn) { ((Button) v).setText("X"); } else { ((Button) v).setText("O"); } roundCount++; if (checkForWin()) { if (player1Turn) { player1Wins(); } else { player2Wins(); } } else if (roundCount == 9) { draw(); } else { player1Turn = !player1Turn; } } private boolean checkForWin() { String[][] field = new String[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { field[i][j] = buttons[i][j].getText().toString(); } } for (int i = 0; i < 3; i++) { if (field[i][0].equals(field[i][1]) && field[i][0].equals(field[i][2]) && !field[i][0].equals("")) { return true; } } for (int i = 0; i < 3; i++) { if (field[0][i].equals(field[1][i]) && field[0][i].equals(field[2][i]) && !field[0][i].equals("")) { return true; } } if (field[0][0].equals(field[1][1]) && field[0][0].equals(field[2][2]) && !field[0][0].equals("")) { return true; } if (field[0][2].equals(field[1][1]) && field[0][2].equals(field[2][0]) && !field[0][2].equals("")) { return true; } return false; } private void player1Wins() { player1Points++; Toast.makeText(this, "Player 1 wins!", Toast.LENGTH_SHORT).show(); updatePointsText(); resetBoard(); } private void player2Wins() { player2Points++; Toast.makeText(this, "Player 2 wins!", Toast.LENGTH_SHORT).show(); updatePointsText(); resetBoard(); } private void draw() { Toast.makeText(this, "Draw!", Toast.LENGTH_SHORT).show(); resetBoard(); } private void updatePointsText() { textViewPlayer1.setText("Player 1: " + player1Points); textViewPlayer2.setText("Player 2: " + player2Points); } private void resetBoard() { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { buttons[i][j].setText(""); } } roundCount = 0; player1Turn = true; } private void resetGame() { player1Points = 0; player2Points = 0; updatePointsText(); resetBoard(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("roundCount", roundCount); outState.putInt("player1Points", player1Points); outState.putInt("player2Points", player2Points); outState.putBoolean("player1Turn", player1Turn); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); roundCount = savedInstanceState.getInt("roundCount"); player1Points = savedInstanceState.getInt("player1Points"); player2Points = savedInstanceState.getInt("player2Points"); player1Turn = savedInstanceState.getBoolean("player1Turn"); } }
پیشنهاد شگفت انگیز کدفرند، دسترسی به تمامی دوره های آموزشی کدفرند تنها با ۹۹ هزار تومان
پروژه اندروید سیستم هوشمند Alaram (سطح پیشرفته)
این اپلیکیشن به گونه ای طراحی شده است که شما را از خواب بیدار کند یا اینکه هنگام گوش دادن به موسیقی یا حرکت با اتوبوس به شما هشدار دهد تا به موقع موسیقی را قطع کنید یا در ایستگاه صحیح پیاده شوید. هنگام باز کردن برنامه از شما یک مقصد درخواست میشود تا به محض رسیدن به آن مقصد اپلیکیشن به شما هشدار دهد. دوره آموزش برنامه نویسی اندروید (کامل)
لوکیشن را میتوانید با استفاده از مپ تنظیم کنید طوری که نقطه آبی رنگ لوکیشن فعلی و قرمز مقصد است. دکمه های save و discard به کاربر اجازه میدهد تا تغییرات را ذخیره یا لغو کند. دکمه toggle در بالا tracker را فعال میکند و الگوریتم این برنامه مسیر را محاسبه کرده و هنگامی که به اندازی کافی نزدیک مقصد باشید، به شما هشدار میدهد.
میتوانید سورس کد این پروژه اندروید را در گیت هاب بررسی کنید.
برچسب:android, Java, kotlin, XML, اندروید, برنامه نویسی, برنامه نویسی اندروید, پروژه های اندروید, جاوا, علوم کامپیوتر, کاتلین