Thứ Tư, 27 Tháng Mười Một 2024
Trang chủLập trìnhSource CodeXây dựng game Freaking Math trên Android - Lập trình android

Xây dựng game Freaking Math trên Android – Lập trình android

DANH SÁCH BÀI VIẾT
Lập trình ứng dụng GamePlay(Trò chơi giải trí offline) trên Android Studio
Lập trình game 2048 trên Android Studio – Mã nguồn game 2048
Lập trình Ứng dụng Máy tính bỏ túi trên Android Studio
Xây dựng game Freaking Math trên Android – Lập trình android

Freaking Math là một tựa game tính toán rất đơn giản. Luật chơi duy nhất là bạn phải lựa chọn kết quả đúng, sai cho một phép toán trong 1 thời gian nhất định.

Trong loạt bài chia sẻ các demo và Source code, hôm nay mình sẽ chia sẻ code Xây dựng game Freaking Math trên Android – Lập trình android được xây dựng trên Android Studio.

Xây dựng game Freaking Math trên Android

Video dưới đây là demo mà mình đã xây dựng và sẽ chia sẻ SourceCode trong bài viết hôm nay, bạn xem qua nhé.

Một số hình ảnh trò chơi

*Màn hình chính

Xây dựng game Freaking Math trên Android - Lập trình android

*Màn hình chọn trò chơi

Xây dựng game Freaking Math trên Android - Lập trình android

*Màn hình chọn cấp độ trò chơi

Xây dựng game Freaking Math trên Android - Lập trình android

*Màn hình trò chơi

Lập trình android

*Màn hình 2 người chơi(Kiểu thi đấu mỗi người 1 phía màn hình)

Lập trình android

*Màn hình game over

Lập trình android

Mã nguồn chương trình

DOWNLOAD Mã nguồn và file APK theo link dưới đây.

TẢI MÃ NGUỒN

Link file Source: https://tuicocach.com/shortlink/?c=freaking_math_source

TẢI FILE APK

Link file .apk: https://tuicocach.com/shortlink/?c=freaking_math-apk

Mã nguồn chương trình gồm một số file Java như sau

Database.java (Lớp Database)

package com.example.freakingmath;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class Database extends SQLiteOpenHelper{
    public Database(@Nullable Context context, @Nullable String name, @Nullable CursorFactory factory, int version) {
        super(context, name, factory, version);
    }
    public void QueryData(String sql)
    {
        SQLiteDatabase cosodulieu = getWritableDatabase();
        cosodulieu.execSQL(sql);
    }
    public Cursor GetData(String sql)
    {
        SQLiteDatabase cosodulieu = getReadableDatabase();
        return cosodulieu.rawQuery(sql,null);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
    public void Create(Context context)
    {
        Database database = new Database(context,"FreakingMath.sqlite",null,1);
        try {
            database.GetData("SELECT * FROM Diemcao");
        }catch (Exception e)
        {
            database.QueryData("CREATE TABLE IF NOT EXISTS DiemCao(id VARCHAR PRIMARY KEY,EASY INTEGER, TRUNGBINH INTEGER, KHO INTEGER)");
            database.QueryData("INSERT INTO Diemcao VALUES('TOF',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('phepcong',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('pheptru',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('phepnhan',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('phepchia',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('all',0,0,0)");
            database.QueryData("INSERT INTO Diemcao VALUES('2NC',0,0,0)");
        }
        database.close();
    }
    public int getScore(Context context,String table, String id, int column){
        Database database = new Database(context,"FreakingMath.sqlite",null,1);
        Cursor cursor = database.GetData("SELECT* FROM "+table);
        while (cursor.moveToNext())
        {
          if(cursor.getString(0).equals(id))break;
        }
        database.close();
        return cursor.getInt(column);
    }
    public void setScore(Context context,String table, String id,String column, int scores)
    {
        Database database = new Database(context,"FreakingMath.sqlite",null,1);
        Cursor cursor = database.GetData("SELECT* FROM "+table);
        database.QueryData("UPDATE "+table+" SET "+column+"="+scores+" WHERE id='"+id+"'");
        database.close(); cursor.close();
    }
}

GameOver.java (Lớp GameOver)

package com.example.freakingmath;

import android.app.*;
import android.content.Intent;
import android.database.Cursor;
import android.view.*;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class GameOver extends Activity {
    private Button back, mainmaenu, playgain;
    private int chuyentumanhinh=0, mucchoi, diemcao;
    private TextView score, highscore;
    private TextView lever;
    Database database;
    String pheptoan = new String();
    Intent it;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent intent = new Intent();
            if(chuyentumanhinh == 1)  intent = new Intent(GameOver.this,MucChoiToF.class);
            else if(chuyentumanhinh == 2)  intent = new Intent(GameOver.this,onePlayer.class);
            startActivity(intent);
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_game_over);
        anhxa();
        chuyentumanhinh = it.getIntExtra("playagain",0);
        mucchoi=it.getIntExtra("mucchoi",0);
        if(chuyentumanhinh==2) pheptoan = it.getStringExtra("pheptoan");
        database = new Database(this,"",null,1);
        if(chuyentumanhinh==1) {
            trueorFalse();
        }else if(chuyentumanhinh==2) onePlayer();
       score.setText("Score: "+String.valueOf(it.getIntExtra("score",0)));
        highscore.setText(("High Score: " +String.valueOf(diemcao)));
        database.close();

        mainmaenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                onDestroy();
                Intent intent = new Intent(GameOver.this,Typeofplay.class);
                finish();
                startActivity(intent);
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                if(chuyentumanhinh == 1)  intent = new Intent(GameOver.this,MucChoiToF.class);
                else if(chuyentumanhinh == 2)  intent = new Intent(GameOver.this,onePlayer.class);
                startActivity(intent);
            }
        });
        playgain.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onDestroy();
                Intent intent = new Intent();
                if(chuyentumanhinh == 1){
                    intent = new Intent(GameOver.this,trueorfalse.class);
                    intent.putExtra("mucchoi",mucchoi);
                }
                else if(chuyentumanhinh == 2){
                    intent = new Intent(GameOver.this,playOnePlayer.class);
                    intent.putExtra("mucchoi",mucchoi);
                    intent.putExtra("pheptoan",pheptoan);
                }
                startActivity(intent);
            }
        });

    }

    public void trueorFalse()
    {
        if(mucchoi==10) {
            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao","TOF",1))
            {
                database.setScore(this,"Diemcao","TOF","EASY",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao","TOF",1);
            lever.setText("Mức độ dễ");
        }else if(mucchoi==100) {
            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao","TOF",2))
            {
                database.setScore(this,"Diemcao","TOF","TRUNGBINH",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao","TOF",2);
            lever.setText("Mức trung bình");
        } else {
            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao","TOF",3))
            {
                database.setScore(this,"Diemcao","TOF","KHO",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao","TOF",3);
            lever.setText("Mức độ khó");
        }
    }

    public void onePlayer()
    {
        if(mucchoi==10) {
            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao",pheptoan,1))
            {
                database.setScore(this,"Diemcao",pheptoan,"EASY",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao",pheptoan,1);
            lever.setText("Mức độ dễ");
        }else if(mucchoi==100) {

            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao",pheptoan,2))
            {
                database.setScore(this,"Diemcao",pheptoan,"TRUNGBINH",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao",pheptoan,2);
            lever.setText("Mức trung bình");
        } else {
            if(it.getIntExtra("score",0) > database.getScore(this,"Diemcao",pheptoan,3))
            {
                database.setScore(this,"Diemcao",pheptoan,"KHO",it.getIntExtra("score",0));
            }
            diemcao = database.getScore(this,"Diemcao",pheptoan,3);
            lever.setText("Mức độ khó");
        }
    }
    private void anhxa()
    {
        it = getIntent();
        back=(Button)findViewById(R.id.back);
        mainmaenu=(Button)findViewById(R.id.mainmenu);
        playgain=(Button)findViewById(R.id.TryAgain);
        score=(TextView)findViewById(R.id.txtScore);
        highscore = (TextView)findViewById(R.id.txtHighScore);
        lever=(TextView)findViewById(R.id.lever);
    }
}

GameOverTwoPlay.java (Lớp GameOverTwoPlay)

package com.example.freakingmath;
import android.app.*;
import android.content.Intent;
import android.view.*;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class GameOverTwoPlay extends Activity {
    private Button back, mainmaenu, playgain;
    private TextView score, highscore;
    Database database;
    Intent it=null;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent intent = new Intent(GameOverTwoPlay.this, Typeofplay.class);
            startActivity(intent);
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_game_over_two_play);
        anhxa();
            int diemcao=0;
            int scr1=it.getIntExtra("score1",0), scr2 = it.getIntExtra("score2",0);
            if(scr1 >= scr2)
            {
                if(scr1 > database.getScore(this,"Diemcao","2NC",1))
                {
                    database.setScore(this,"Diemcao","2NC","EASY",scr1);
                }
            }else if(scr2 > database.getScore(this,"Diemcao","2NC",1)){
                database.setScore(this,"Diemcao","2NC","EASY",scr2);
            }
            diemcao = database.getScore(this,"Diemcao","2NC",1);

        score.setText(String.valueOf(scr1) +" - " + String.valueOf(scr2)) ;
        highscore.setText(("High Score: " +String.valueOf(diemcao)));
        database.close();
        mainmaenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onDestroy();
                Intent intent = new Intent(GameOverTwoPlay.this,MainActivity.class);
                finish();
                startActivity(intent);
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(GameOverTwoPlay.this, Typeofplay.class);
                startActivity(intent);
            }
        });
        playgain.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onDestroy();
                Intent intent = new Intent(GameOverTwoPlay.this, playTwoPlayer.class);
                startActivity(intent);
            }
        });
    }

    private void anhxa()
    {
        database = new Database(this,"",null,1);
        it = getIntent();
        back=(Button)findViewById(R.id.back);
        mainmaenu=(Button)findViewById(R.id.mainmenu);
        playgain=(Button)findViewById(R.id.TryAgain);
        score=(TextView)findViewById(R.id.scores);
        highscore = (TextView)findViewById(R.id.txtHighScore);
    }
}

HighScore.java (Lớp HighScore)

package com.example.freakingmath;

import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.app.*;

public class HighScore extends Activity {
    private Button back;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            startActivity(new Intent(HighScore.this, MainActivity.class));
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.highscores);
        back = (Button)findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(HighScore.this, MainActivity.class));
            }
        });
        Database dtb = new Database(this,"",null,1);
        TextView TOF_de, TOF_tb, TOF_kho,Hainguoichoi;
        TextView oneplay11,oneplay12, oneplay13;
        TextView oneplay21,oneplay22, oneplay23;
        TextView oneplay31,oneplay32, oneplay33;
        TextView oneplay41,oneplay42, oneplay43;
        TextView oneplay51,oneplay52, oneplay53;

        TOF_de = (TextView)findViewById(R.id.TOFde);
        TOF_tb = (TextView)findViewById(R.id.TOFtb);
        TOF_kho = (TextView)findViewById(R.id.TOFkho);
        oneplay11=(TextView)findViewById(R.id.oneplay11);
        oneplay12=(TextView)findViewById(R.id.oneplay12);
        oneplay13=(TextView)findViewById(R.id.oneplay13);
        oneplay21=(TextView)findViewById(R.id.oneplay21);
        oneplay22=(TextView)findViewById(R.id.oneplay22);
        oneplay23=(TextView)findViewById(R.id.oneplay23);
        oneplay31=(TextView)findViewById(R.id.oneplay31);
        oneplay32=(TextView)findViewById(R.id.oneplay32);
        oneplay33=(TextView)findViewById(R.id.oneplay33);
        oneplay41=(TextView)findViewById(R.id.oneplay41);
        oneplay42=(TextView)findViewById(R.id.oneplay42);
        oneplay43=(TextView)findViewById(R.id.oneplay43);
        oneplay51=(TextView)findViewById(R.id.oneplay51);
        oneplay52=(TextView)findViewById(R.id.oneplay52);
        oneplay53=(TextView)findViewById(R.id.oneplay53);

        Hainguoichoi=(TextView)findViewById(R.id.hainguoichoi);
        TOF_de.setText(String.valueOf(dtb.getScore(this,"Diemcao","TOF",1)));
        TOF_tb.setText(String.valueOf(dtb.getScore(this,"Diemcao","TOF",2)));
        TOF_kho.setText(String.valueOf(dtb.getScore(this,"Diemcao","TOF",3)));
        Hainguoichoi.setText(String.valueOf(dtb.getScore(this,"Diemcao","2NC",1)));
        oneplay11.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepcong",1)));
        oneplay12.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepcong",2)));
        oneplay13.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepcong",3)));
        oneplay21.setText(String.valueOf(dtb.getScore(this,"Diemcao","pheptru",1)));
        oneplay22.setText(String.valueOf(dtb.getScore(this,"Diemcao","pheptru",2)));
        oneplay23.setText(String.valueOf(dtb.getScore(this,"Diemcao","pheptru",3)));
        oneplay31.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepnhan",1)));
        oneplay32.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepnhan",2)));
        oneplay33.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepnhan",3)));
        oneplay41.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepchia",1)));
        oneplay42.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepchia",2)));
        oneplay43.setText(String.valueOf(dtb.getScore(this,"Diemcao","phepchia",3)));
        oneplay51.setText(String.valueOf(dtb.getScore(this,"Diemcao","all",1)));
        oneplay52.setText(String.valueOf(dtb.getScore(this,"Diemcao","all",2)));
        oneplay53.setText(String.valueOf(dtb.getScore(this,"Diemcao","all",3)));
        dtb.close();

    }
}

MainActivity.jav (Lớp MainActivity)

package com.example.freakingmath;

import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.*;
import android.view.*;
import android.widget.Button;
public class MainActivity extends Activity {
    private Button btntacgia, choingay, setting, highscore;
    private MediaPlayer media;
    private Database database;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        anhxa();
        database.Create(this);
        media=MediaPlayer.create(MainActivity.this, R.raw.startgame);
        media.setLooping(true);
        media.start();
        btntacgia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                media.stop();
                LazyTeam();
            }
        });
        choingay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                media.stop();
                Intent intent = new Intent(MainActivity.this, Typeofplay.class);
                startActivity(intent);
            }
        });
        setting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialongsetting();
            }
        });
        highscore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                media.stop();
                startActivity(new Intent(MainActivity.this, HighScore.class) );
            }
        });
    }
    public void LazyTeam()
    {
        Dialog dialog= new Dialog(this);
        dialog.setContentView(R.layout.activity_author);
        dialog.show();
    }
    public void dialongsetting()
    {
        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_setting);
        dialog.show();
    }
    public void anhxa()
    {
        database =  new Database(this,"",null,1);
        btntacgia=(Button)findViewById(R.id.tacgia);
        choingay=(Button)findViewById(R.id.choingay);
        setting=(Button)findViewById(R.id.setting);
        highscore =(Button)findViewById(R.id.highscore);
    }
}

MucChoi1NC.java (Lớp MucChoi1NC)

package com.example.freakingmath;

import androidx.appcompat.app.AppCompatActivity;
import android.app.*;
import android.content.Intent;
import android.view.*;
import android.os.Bundle;
import android.widget.Button;

public class MucChoi1NC extends Activity {
    private Button back, de, kho, trungbinh;
    private Intent intent;
    private String pheptoan;
    int mucchoi;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            startActivity(new Intent(MucChoi1NC.this, onePlayer.class));
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_muc_choi);
        Anhxa();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MucChoi1NC.this, onePlayer.class));
            }
        });
        de.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(MucChoi1NC.this,playOnePlayer.class);
                it.putExtra("mucchoi",10);
                it.putExtra("pheptoan",pheptoan);
                startActivity(it);
            }
        });
        trungbinh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(MucChoi1NC.this,playOnePlayer.class);
                it.putExtra("mucchoi",100);
                it.putExtra("pheptoan",pheptoan);
                startActivity(it);
            }
        });
        kho.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(MucChoi1NC.this,playOnePlayer.class);
                it.putExtra("mucchoi", 1000);
                it.putExtra("pheptoan",pheptoan);
                startActivity(it);
            }
        });
    }
    void Anhxa()
    {
        back=(Button)findViewById(R.id.back);
        de=(Button)findViewById(R.id.easy);
        trungbinh=(Button)findViewById(R.id.normal);
        kho=(Button)findViewById(R.id.difficult);
        intent = getIntent();
        pheptoan = intent.getStringExtra("pheptoan");
    }
}

MucChoiToF.java (Lớp MucChoiToF)

package com.example.freakingmath;

import android.content.Intent;
import android.view.*;
import android.app.*;
import android.os.Bundle;
import android.widget.Button;

public class MucChoiToF extends Activity {
    private Button back, easy, normal,difficult;
    private int mucchoi;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent intent = new Intent(MucChoiToF.this, Typeofplay.class);
            startActivity(intent);
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_muc_choi);
        anhxa();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MucChoiToF.this, Typeofplay.class);
                startActivity(intent);
            }
        });
        easy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MucChoiToF.this, trueorfalse.class);
                intent.putExtra("mucchoi",10);
                intent.putExtra("playagain",1);
                startActivity(intent);
            }
        });
        normal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MucChoiToF.this, trueorfalse.class);
                intent.putExtra("mucchoi",100);
                intent.putExtra("playagain",1);
                startActivity(intent);
            }
        });
        difficult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MucChoiToF.this, trueorfalse.class);
                intent.putExtra("playagain",1);
                intent.putExtra("mucchoi",1000);
                startActivity(intent);
            }
        });
    }
    private void anhxa()
    {
        back=(Button)findViewById(R.id.back);
        easy=(Button)findViewById(R.id.easy);
        normal=(Button)findViewById(R.id.normal);
        difficult=(Button)findViewById(R.id.difficult);
    }
}

onePlayer.java (Lớp onePlayer)

package com.example.freakingmath;

import androidx.appcompat.app.AppCompatActivity;
import android.app.*;
import android.content.Intent;
import android.view.*;

import android.os.Bundle;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class onePlayer extends Activity {
    private TextView back;
    private LinearLayout phepcong, pheptru,phepnhan,phepchia,phepall;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            startActivity(new Intent(onePlayer.this, Typeofplay.class));
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_one_player);
        anhxa();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(onePlayer.this, Typeofplay.class));
            }
        });
        phepcong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(onePlayer.this,MucChoi1NC.class);
                intent.putExtra("pheptoan","phepcong");
                intent.putExtra("playagain",2);
                startActivity(intent);
            }
        });
        pheptru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(onePlayer.this,MucChoi1NC.class);
                intent.putExtra("pheptoan","pheptru");
                intent.putExtra("playagain",2);
                startActivity(intent);
            }
        });
        phepnhan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(onePlayer.this,MucChoi1NC.class);
                intent.putExtra("pheptoan","phepnhan");
                intent.putExtra("playagain",2);
                startActivity(intent);
            }
        });
        phepchia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(onePlayer.this,MucChoi1NC.class);
                intent.putExtra("pheptoan","phepchia");
                startActivity(intent);
            }
        });
        phepall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(onePlayer.this,MucChoi1NC.class);
                intent.putExtra("pheptoan","all");
                startActivity(intent);
            }
        });
    }
    private void anhxa()
    {
        back=(TextView) findViewById(R.id.back);
        phepcong=(LinearLayout)findViewById(R.id.Phepcong);
        pheptru=(LinearLayout)findViewById(R.id.Pheptru);
        phepnhan=(LinearLayout)findViewById(R.id.Phepnhan);
        phepchia=(LinearLayout)findViewById(R.id.Phepchia);
        phepall=(LinearLayout)findViewById(R.id.Phepall);
    }
}

playOnePlayer.java (Lớp playOnePlayer)

package com.example.freakingmath;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.CountDownTimer;
import android.view.*;
import android.app.*;
import android.os.Bundle;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.Random;

public class playOnePlayer extends Activity {
    private Button a, b, c, d;
    private TextView txt, score;
    private String pheptoan;
    int mucchoi;
    private Intent it;
    private CountDownTimer cTimer1 = null;
    private SeekBar seekBar;
    private int tg = 39;
    private int dapandung;
    private int scores=0;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_play_one_player);
        Anhxa();
        startTimer1();
        RandomQuestion();
        a.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               try{
                   if(dapandung==1)lvup();
                   else{
                       thuagame();
                   }
               }catch (Exception e){}
            }
        });
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(dapandung==2)lvup();
                    else{
                        thuagame();
                    }
                }catch (Exception e){}
            }
        });
        c.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               try{
                   if(dapandung==3)lvup();
                   else{
                       thuagame();
                   }
               }catch ( Exception e){}
            }
        });
        d.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(dapandung==4)lvup();
                    else{
                        thuagame();
                    }
                }catch (Exception e){}
            }
        });
    }
    public void lvup(){
        MediaPlayer player;
        player = MediaPlayer.create(this, R.raw.quaman);
        player.start();
        scores++; cTimer1.cancel();
        tg=39;
        score.setText("Scores: "+String.valueOf(scores));
        startTimer1();
        RandomQuestion();
    }
    public void thuagame()
    {
        MediaPlayer player;
        player = MediaPlayer.create(this, R.raw.thuacuoc);
        player.start();
        cTimer1.cancel();
        onDestroy();
        Intent intent = new Intent(playOnePlayer.this, GameOver.class);
        intent.putExtra("mucchoi", mucchoi);
        intent.putExtra("pheptoan",pheptoan);
        intent.putExtra("playagain", 2);
        intent.putExtra("score",scores);
        startActivity(intent);
    }
    public void startTimer1() {
        cTimer1 = new CountDownTimer(4000, 100) {
            public void onTick(long millisUntilFinished) {
                tg--;
                seekBar.setProgress(tg);
            }
            public void onFinish() {
                thuagame();
            }
        };
        cTimer1.start();
    }
    public void randomPhepcong()
    {
        Random random = new Random();
        dapandung = random.nextInt(4)+1;
        int nb1,nb2,nb3;
        nb1=random.nextInt(mucchoi); nb2=random.nextInt(mucchoi);
        txt.setText(String.valueOf(nb1)+ " + " +String.valueOf(nb2)+" = ?");
        nb3=nb1+nb2;
        int arr[] = new int[4];
        for(int i=0;i<4;i++)
        {
            arr[i]=random.nextInt(Math.max(nb1,nb2)+1)+Math.min(nb1,nb2);
            if(arr[i]==nb3) i--;
        }
        a.setText(String.valueOf(arr[0]));
        b.setText(String.valueOf(arr[1]));
        c.setText(String.valueOf(arr[2]));
        d.setText(String.valueOf(arr[3]));
        if(dapandung==1) a.setText(String.valueOf(nb3));
        else if(dapandung==2) b.setText(String.valueOf(nb3));
        else if(dapandung==3) c.setText(String.valueOf(nb3));
        else if(dapandung==4) d.setText(String.valueOf(nb3));
    }
    public void randomPheptru()
    {
        Random random = new Random();
        dapandung = random.nextInt(4)+1;
        int nb1,nb2,nb3;
        nb1=random.nextInt(mucchoi);
        do{
            nb2=random.nextInt(mucchoi);
        }while (nb2>=nb1);
        txt.setText(String.valueOf(nb1)+" - "+String.valueOf(nb2)+" = ?");
        nb3=nb1-nb2;
        int arr[] = new int[4];
        for(int i=0;i<4;i++)
        {
            arr[i]=random.nextInt(Math.max(nb1,nb2)+1)+Math.min(nb1,nb2);
            if(arr[i]==nb3) i--;
        }
        a.setText(String.valueOf(arr[0]));
        b.setText(String.valueOf(arr[1]));
        c.setText(String.valueOf(arr[2]));
        d.setText(String.valueOf(arr[3]));
        if(dapandung==1) a.setText(String.valueOf(nb3));
        else if(dapandung==2) b.setText(String.valueOf(nb3));
        else if(dapandung==3) c.setText(String.valueOf(nb3));
        else if(dapandung==4) d.setText(String.valueOf(nb3));
    }
    public void randomphepnhan()
    {
        int mucchoi1=10;
        if(mucchoi==100) mucchoi1=40;
        else if(mucchoi==1000) mucchoi1=90;
        Random random = new Random();
        dapandung = random.nextInt(4)+1;
        int nb1,nb2,nb3;
        nb1=random.nextInt(mucchoi1);
        nb2=random.nextInt(mucchoi1);
        txt.setText(String.valueOf(nb1)+" * "+String.valueOf(nb2)+" = ?");
        nb3=nb1*nb2;
        int arr[] = new int[4];
        for(int i=0;i<4;i++)
        {
            arr[i]=random.nextInt((Math.max(nb1,nb2)*Math.max(nb1,nb2)+1) - (Math.min(nb1,nb2)*Math.min(nb1,nb2))) + (Math.min(nb1,nb2)*Math.min(nb1,nb2));
            if(arr[i]==nb3) i--;
        }
        a.setText(String.valueOf(arr[0]));
        b.setText(String.valueOf(arr[1]));
        c.setText(String.valueOf(arr[2]));
        d.setText(String.valueOf(arr[3]));
        if(dapandung==1) a.setText(String.valueOf(nb3));
        else if(dapandung==2) b.setText(String.valueOf(nb3));
        else if(dapandung==3) c.setText(String.valueOf(nb3));
        else if(dapandung==4) d.setText(String.valueOf(nb3));
    }
    public void randomPhepchia()
    {
        int mucchoi1=10;
        if(mucchoi==100) mucchoi1=40;
        else if(mucchoi==1000) mucchoi1=90;
        Random random = new Random();
        dapandung = random.nextInt(4)+1;
        int nb1,nb2,nb3;
        nb2=random.nextInt(mucchoi1);
        nb3=random.nextInt(mucchoi1);
        nb1=nb3*nb2;
        txt.setText(String.valueOf(nb1)+" / "+String.valueOf(nb2)+" = ?");
        int arr[] = new int[4];
        for(int i=0;i<4;i++)
        {
            arr[i]=random.nextInt(11)+1;
            if(arr[i]==nb1) i--;
        }
        a.setText(String.valueOf(arr[0]));
        b.setText(String.valueOf(arr[1]));
        c.setText(String.valueOf(arr[2]));
        d.setText(String.valueOf(arr[3]));
        if(dapandung==1) a.setText(String.valueOf(nb3));
        else if(dapandung==2) b.setText(String.valueOf(nb3));
        else if(dapandung==3) c.setText(String.valueOf(nb3));
        else if(dapandung==4) d.setText(String.valueOf(nb3));
    }
    public void RandomQuestion()
    {
        if(pheptoan.equals("phepcong") == true)
        {
            randomPhepcong();
        }else  if(pheptoan.equals("pheptru") == true){
            randomPheptru();
        }else  if(pheptoan.equals("phepnhan") == true)
        {
            randomphepnhan();
        }else if(pheptoan.equals("phepchia") == true)
        {
            randomPhepchia();
        }else{
            Random random = new Random();
            int operations=random.nextInt(4)+1;
            if(operations==1){
                randomPhepcong();
            }else if(operations==2){
                randomPheptru();
            }else if(operations==3){
                randomphepnhan();
            }else{
                randomPhepchia();
            }
        }
    }
    void Anhxa()
    {
        a=(Button)findViewById(R.id.answerplayera);
        b=(Button)findViewById(R.id.answerplayerb);
        c=(Button)findViewById(R.id.answerplayerc);
        d=(Button)findViewById(R.id.answerplayerd);
        it=getIntent() ;
        seekBar=(SeekBar)findViewById(R.id.seekbar);
        txt=(TextView)findViewById(R.id.txt);
        score=(TextView)findViewById(R.id.sorce);
        mucchoi=it.getIntExtra("mucchoi",1);
        pheptoan=it.getStringExtra("pheptoan");
    }
}

playTwoPlayer.java (Lớp playTwoPlayer)

package com.example.freakingmath;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.*;
import android.app.*;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.Random;

public class playTwoPlayer extends Activity {
    private Button btnPlayer1a, btnPlayer1b, btnPlayer1c, btnPlayer1d;
    private Button btnPlayer2a, btnPlayer2b, btnPlayer2c, btnPlayer2d;
    TextView questionPlayer1, questionPlayer2, scoresPlayer1, scoresPlayer2;
    SeekBar seekBarPlayer1, seekBarPlayer2;
    private CountDownTimer cTimer1 = null;
    private MediaPlayer media=null;
    private int tg1=39, tg2=39;
    private boolean isOver1 = false, isOver2=false;
    int dapandung=0, dapandung1=0, scores1=0, scores2=0;
    @Override

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            //preventing default implementation previous to android.os.Build.VERSION_CODES.ECLAIR
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_twoplayers);
        anhxa();
        startTimer1();
        RandomPlayer1();
        RandomPlayer2();
        btnPlayer1();
        btnPlayer2();
    }


    public void startTimer1() {
        cTimer1 = new CountDownTimer(4100, 100) {
            public void onTick(long millisUntilFinished) {
                try{
                    seekBarPlayer1.setProgress(tg1);
                    seekBarPlayer2.setProgress(tg2);
                    if(tg1==0){
                        isOver1=true;questionPlayer1.setText("GAME OVER");
                    }else tg1--;
                    if(tg2==0) {
                        isOver2=true;questionPlayer2.setText("GAME OVER");
                    }else tg2--;
                }catch (Exception e){}
            }
            public void onFinish() {
                thuaman();
            }
        };
        cTimer1.start();
    }
    public void quaman()
    {
        media= MediaPlayer.create(playTwoPlayer.this,R.raw.quaman);
        media.start();
    }
    public void thuaman()
    {
        try{
            media= MediaPlayer.create(playTwoPlayer.this,R.raw.thuacuoc);
            media.start();
            onDestroy();
            Intent it = new Intent(playTwoPlayer.this, GameOverTwoPlay.class);
            it.putExtra("score1", scores1);
            it.putExtra("score2",scores2);
            startActivity(it);
        }catch (Exception e){}
    }
    public void btnPlayer2()
    {

        btnPlayer2a.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver2==false)
                    {
                        if(dapandung!=1){
                            isOver2=true; RandomPlayer2(); tg2=0;questionPlayer2.setText("GAME OVER");
                        }
                        else {
                            quaman();
                            cTimer1.cancel(); tg2=39;startTimer1();RandomPlayer2();
                            scores2++; scoresPlayer2.setText("Scores: "+String.valueOf(scores2));
                        }
                    }
                }catch (Exception e){}
            }
        });
        btnPlayer2b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               try{
                    if(isOver2==false)
                    {
                        if(dapandung!=2){
                            isOver2=true; RandomPlayer2(); tg2=0;questionPlayer2.setText("GAME OVER");
                        }
                        else {
                            quaman();
                            cTimer1.cancel(); tg2=39;startTimer1();RandomPlayer2();
                            scores2++; scoresPlayer2.setText("Scores: "+String.valueOf(scores2));
                        }
                    }
                }catch (Exception e){}
            }
        });
        btnPlayer2c.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver2==false)
                    {
                        if(dapandung!=3){
                            isOver2=true; RandomPlayer2(); tg2=0;questionPlayer2.setText("GAME OVER");
                        }
                        else {
                            quaman();
                            cTimer1.cancel(); tg2=39;startTimer1();RandomPlayer2();
                            scores2++; scoresPlayer2.setText("Scores: "+String.valueOf(scores2));
                        }
                    }
                }catch (Exception e){}
            }
        });
        btnPlayer2d.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver2==false)
                    {
                        if(dapandung!=4){
                            isOver2=true; tg2=0; RandomPlayer2(); questionPlayer2.setText("GAME OVER");
                        }
                        else{
                            quaman();
                            scores2++; scoresPlayer2.setText("Scores: "+String.valueOf(scores2));
                            cTimer1.cancel(); tg2=39;startTimer1();RandomPlayer2();
                        }
                    }
                }catch (Exception e){}
            }
        });
    }
    public void btnPlayer1()
    {
        btnPlayer1a.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver1==false)
                    {
                        if(dapandung1!=1){
                            isOver1=true;tg1=0;questionPlayer1.setText("GAME OVER");
                        }
                        else{
                            quaman();
                            scores1++; scoresPlayer1.setText("Scores: "+String.valueOf(scores1));
                            cTimer1.cancel(); tg1=39;startTimer1();RandomPlayer1();
                        }
                    }
                }catch (Exception e) {}
            }
        });
        btnPlayer1b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver1==false)
                    {
                        if(dapandung1!=2){
                            isOver1=true;tg1=0;questionPlayer1.setText("GAME OVER");
                        }
                        else{
                            quaman();
                            scores1++; scoresPlayer1.setText("Scores: "+String.valueOf(scores1));
                            cTimer1.cancel(); tg1=39;startTimer1();RandomPlayer1();
                        }
                    }
                }catch (Exception e){}
            }
        });
        btnPlayer1c.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               try{
                   if(isOver1==false)
                   {
                       if(dapandung1!=3){
                           isOver1=true;tg1=0;questionPlayer1.setText("GAME OVER");
                       }
                       else{
                           quaman();
                           scores1++; scoresPlayer1.setText("Scores: "+String.valueOf(scores1));
                           cTimer1.cancel(); tg1=39;startTimer1();RandomPlayer1();
                       }
                   }
               }catch (Exception e){}
            }
        });
        btnPlayer1d.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if(isOver1==false)
                    {
                        if(dapandung1!=4){
                            isOver1=true;tg1=0;questionPlayer1.setText("GAME OVER");
                        }
                        else{
                            quaman();
                            scores1++; scoresPlayer1.setText("Scores: "+String.valueOf(scores1));
                            cTimer1.cancel(); tg1=39;startTimer1();RandomPlayer1();
                        }
                    }
                }catch (Exception e){}
            }
        });
    }
    public void RandomPlayer2()
    {
        Random random = new Random();
        int a,b,c;
        int operations=random.nextInt(4)+1;
        if(operations==1){
            dapandung = random.nextInt(4)+1;
            a=random.nextInt(20); b=random.nextInt(20);
            questionPlayer2.setText(String.valueOf(a)+" + "+String.valueOf(b)+" = ?");
            c=a+b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(Math.max(a,b)+1)+Math.min(a,b);
                if(arr[i]==c) i--;
            }
            btnPlayer2a.setText(String.valueOf(arr[0]));
            btnPlayer2b.setText(String.valueOf(arr[1]));
            btnPlayer2c.setText(String.valueOf(arr[2]));
            btnPlayer2d.setText(String.valueOf(arr[3]));
            if(dapandung==1) btnPlayer2a.setText(String.valueOf(c));
            else if(dapandung==2) btnPlayer2b.setText(String.valueOf(c));
            else if(dapandung==3) btnPlayer2c.setText(String.valueOf(c));
            else if(dapandung==4) btnPlayer2d.setText(String.valueOf(c));
        }else if(operations==2)
        {
            dapandung = random.nextInt(4)+1;
            a=random.nextInt(30);
            do{
                b=random.nextInt(20);
            }while (a<b);
            questionPlayer2.setText(String.valueOf(a)+" - "+String.valueOf(b)+" = ?");
            c=a-b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(Math.max(a,b)-Math.min(a,b)+1)+Math.min(a,b);
                if(arr[i]==c) i--;
            }
            btnPlayer2a.setText(String.valueOf(arr[0]));
            btnPlayer2b.setText(String.valueOf(arr[1]));
            btnPlayer2c.setText(String.valueOf(arr[2]));
            btnPlayer2d.setText(String.valueOf(arr[3]));
            if(dapandung==1) btnPlayer2a.setText(String.valueOf(c));
            else if(dapandung==2) btnPlayer2b.setText(String.valueOf(c));
            else if(dapandung==3) btnPlayer2c.setText(String.valueOf(c));
            else if(dapandung==4) btnPlayer2d.setText(String.valueOf(c));
        }else if(operations==3)
        {
            dapandung = random.nextInt(4)+1;
            a=random.nextInt(11);
                b=random.nextInt(11);
            questionPlayer2.setText(String.valueOf(a)+" x "+String.valueOf(b)+" = ?");
            c=a*b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt((Math.max(a,b)*Math.max(a,b)) - (Math.min(a,b)*Math.min(a,b))+1) + (Math.min(a,b)*Math.min(a,b));
                if(arr[i]==c) i--;
            }
            btnPlayer2a.setText(String.valueOf(arr[0]));
            btnPlayer2b.setText(String.valueOf(arr[1]));
            btnPlayer2c.setText(String.valueOf(arr[2]));
            btnPlayer2d.setText(String.valueOf(arr[3]));
            if(dapandung==1) btnPlayer2a.setText(String.valueOf(c));
            else if(dapandung==2) btnPlayer2b.setText(String.valueOf(c));
            else if(dapandung==3) btnPlayer2c.setText(String.valueOf(c));
            else if(dapandung==4) btnPlayer2d.setText(String.valueOf(c));
        }else {
            dapandung = random.nextInt(4)+1;
            b=random.nextInt(11);
            c=random.nextInt(11);
            a=c*b;
            questionPlayer2.setText(String.valueOf(a)+" / "+String.valueOf(b)+" = ?");
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(11)+1;
                if(arr[i]==c) i--;
            }
            btnPlayer2a.setText(String.valueOf(arr[0]));
            btnPlayer2b.setText(String.valueOf(arr[1]));
            btnPlayer2c.setText(String.valueOf(arr[2]));
            btnPlayer2d.setText(String.valueOf(arr[3]));
            if(dapandung==1) btnPlayer2a.setText(String.valueOf(c));
            else if(dapandung==2) btnPlayer2b.setText(String.valueOf(c));
            else if(dapandung==3) btnPlayer2c.setText(String.valueOf(c));
            else if(dapandung==4) btnPlayer2d.setText(String.valueOf(c));
        }
    }
    public void RandomPlayer1()
    {
        Random random = new Random();
        int a,b,c;
        int operations=random.nextInt(4)+1;
        if(operations==1){
            dapandung1 = random.nextInt(4)+1;
            a=random.nextInt(20); b=random.nextInt(20);
            questionPlayer1.setText(String.valueOf(a)+" + "+String.valueOf(b)+" = ?");
            c=a+b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(Math.max(a,b)+1)+Math.min(a,b);
                if(arr[i]==c) i--;
            }
            btnPlayer1a.setText(String.valueOf(arr[0]));
            btnPlayer1b.setText(String.valueOf(arr[1]));
            btnPlayer1c.setText(String.valueOf(arr[2]));
            btnPlayer1d.setText(String.valueOf(arr[3]));
            if(dapandung1==1) btnPlayer1a.setText(String.valueOf(c));
            else if(dapandung1==2) btnPlayer1b.setText(String.valueOf(c));
            else if(dapandung1==3) btnPlayer1c.setText(String.valueOf(c));
            else if(dapandung1==4) btnPlayer1d.setText(String.valueOf(c));
        }else if(operations==2)
        {
            dapandung1 = random.nextInt(4)+1;
            a=random.nextInt(30);
            do{
                b=random.nextInt(20);
            }while (a<=b);
            questionPlayer1.setText(String.valueOf(a)+" - "+String.valueOf(b)+" = ?");
            c=a-b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(Math.max(a,b)-Math.min(a,b) + 1)+Math.min(a,b);
                if(arr[i]==c) i--;
            }
            btnPlayer1a.setText(String.valueOf(arr[0]));
            btnPlayer1b.setText(String.valueOf(arr[1]));
            btnPlayer1c.setText(String.valueOf(arr[2]));
            btnPlayer1d.setText(String.valueOf(arr[3]));
            if(dapandung==1) btnPlayer1a.setText(String.valueOf(c));
            else if(dapandung1==2) btnPlayer1b.setText(String.valueOf(c));
            else if(dapandung1==3) btnPlayer1c.setText(String.valueOf(c));
            else if(dapandung1==4) btnPlayer1d.setText(String.valueOf(c));
        }else if(operations==3)
        {
            dapandung1 = random.nextInt(4)+1;
            a=random.nextInt(11);
            b=random.nextInt(11);
            questionPlayer1.setText(String.valueOf(a)+" x "+String.valueOf(b)+" = ?");
            c=a*b;
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt((Math.max(a,b)*Math.max(a,b) +1) - (Math.min(a,b)*Math.min(a,b))) + (Math.min(a,b)*Math.min(a,b));
                if(arr[i]==c) i--;
            }
            btnPlayer1a.setText(String.valueOf(arr[0]));
            btnPlayer1b.setText(String.valueOf(arr[1]));
            btnPlayer1c.setText(String.valueOf(arr[2]));
            btnPlayer1d.setText(String.valueOf(arr[3]));
            if(dapandung1==1) btnPlayer1a.setText(String.valueOf(c));
            else if(dapandung1==2) btnPlayer1b.setText(String.valueOf(c));
            else if(dapandung1==3) btnPlayer1c.setText(String.valueOf(c));
            else if(dapandung1==4) btnPlayer1d.setText(String.valueOf(c));
        }else if(operations==4)
        {
            dapandung1 = random.nextInt(4)+1;
            b=random.nextInt(11);
            c=random.nextInt(11);
            a=c*b;
            questionPlayer1.setText(String.valueOf(a)+" / "+String.valueOf(b)+" = ?");
            int arr[] = new int[4];
            for(int i=0;i<4;i++)
            {
                arr[i]=random.nextInt(11)+1;
                if(arr[i]==a) i--;
            }
            btnPlayer1a.setText(String.valueOf(arr[0]));
            btnPlayer1b.setText(String.valueOf(arr[1]));
            btnPlayer1c.setText(String.valueOf(arr[2]));
            btnPlayer1d.setText(String.valueOf(arr[3]));
            if(dapandung1==1) btnPlayer1a.setText(String.valueOf(c));
            else if(dapandung1==2) btnPlayer1b.setText(String.valueOf(c));
            else if(dapandung1==3) btnPlayer1c.setText(String.valueOf(c));
            else if(dapandung1==4) btnPlayer1d.setText(String.valueOf(c));
        }
    }
    void anhxa()
    {
        btnPlayer1a=(Button)findViewById(R.id.answerplayer1a);
        btnPlayer1b=(Button)findViewById(R.id.answerplayer1b);
        btnPlayer1c=(Button)findViewById(R.id.answerplayer1c);
        btnPlayer1d=(Button)findViewById(R.id.answerplayer1d);

        btnPlayer2a=(Button)findViewById(R.id.answerplayer2a);
        btnPlayer2b=(Button)findViewById(R.id.answerplayer2b);
        btnPlayer2c=(Button)findViewById(R.id.answerplayer2c);
        btnPlayer2d=(Button)findViewById(R.id.answerplayer2d);

        questionPlayer1=(TextView)findViewById(R.id.questionplayer1);
        questionPlayer2=(TextView)findViewById(R.id.questionplayer2);

        scoresPlayer1=(TextView)findViewById(R.id.scores1);
        scoresPlayer2=(TextView)findViewById(R.id.scores2);

        seekBarPlayer1=(SeekBar)findViewById(R.id.seekbar1);
        seekBarPlayer2=(SeekBar)findViewById(R.id.seekbar2);
    }
}

trueorfalse.java (Lớp trueorfalse)

package com.example.freakingmath;

import androidx.appcompat.app.AppCompatActivity;
import android.app.*;
import android.content.Intent;
import android.media.MediaPlayer;
import android.mtp.MtpConstants;
import android.os.CountDownTimer;
import android.view.*;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.Random;

public class trueorfalse extends Activity {
    private CountDownTimer cTimer = null;
    private TextView txt;
    private LinearLayout btntrue, btnfalse;
    private SeekBar seekBar;
    private int tg=39;
    private int number1=0, number2=0, result=0;
    private boolean check;
    private int mucchoi;
    private int score=0;
    private TextView sc;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            //preventing default implementation previous to android.os.Build.VERSION_CODES.ECLAIR
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_trueorfalse);
        anhxa();
        randomInput();
        newCountTime();
        btntrue.setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View v) {
                    if(check==true)
                    {
                        quaman();
                    }else Thuagame();
            }
        });
        btnfalse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    if(check==false)
                    {
                        quaman();
                    }else Thuagame();
            }
        });
    }
    void newCountTime()
    {
        cTimer= new CountDownTimer(4100,100) {
            @Override
            public void onTick(long millisUntilFinished) {
                tg--;
                seekBar.setProgress(tg);
            }
            @Override
            public void onFinish() {
                Thuagame();
            }
        };
        cTimer.start();
    }

    public void quaman()
    {
        MediaPlayer media=MediaPlayer.create(trueorfalse.this,R.raw.quaman);
        media.start(); cTimer.cancel();
        score++; tg=39;
        sc.setText("Scores: "+String.valueOf(score));
        randomInput();
        newCountTime();
    }
    private void Thuagame()
    {
          MediaPlayer media=MediaPlayer.create(trueorfalse.this,R.raw.thuacuoc);
           media.start();
           cTimer.cancel();
           onDestroy();
           Intent it = new Intent(trueorfalse.this, GameOver.class);
           it.putExtra("playagain",1);
           it.putExtra("mucchoi",mucchoi);
           it.putExtra("score", score);
           startActivity(it);
    }
    public void randomInput()
    {
        Random random = new Random();
        int temp = random.nextInt(2);
        number1 = random.nextInt(mucchoi);
        number2 = random.nextInt(mucchoi);
        if(temp==0){
            check=false;
            temp = random.nextInt(2);
            if(temp==0)
            {
                result = random.nextInt(Math.max(number1,number2)+1)+Math.min(number1,number2);
            }else{
                while(number1 < 1 && number1 < number2){
                    number1 = random.nextInt(mucchoi);
                    number2 = random.nextInt(mucchoi);
                }
                result = random.nextInt(Math.min(number1,number2)+1);
            }
            txt.setText(String.valueOf(number1)+" - "+String.valueOf(number2)+" = "+String.valueOf(result));
        }else{
            check=true;
            temp = random.nextInt(2);
            if(temp==0)
            {
                result = number1+number2;
                txt.setText(String.valueOf(number1)+" + "+String.valueOf(number2)+" = "+String.valueOf(result));
            }else{
                while(number1 < 1 && number1 < number2){
                    number1 = random.nextInt(mucchoi);
                    number2 = random.nextInt(mucchoi);
                }
                result = number1-number2;
                txt.setText(String.valueOf(number1)+" - "+String.valueOf(number2)+" = "+String.valueOf(result));
            }
        }
    }
    private void anhxa(){
        txt=(TextView)findViewById(R.id.txt);
        btnfalse=(LinearLayout)findViewById(R.id.btnFalse);
        btntrue=(LinearLayout)findViewById(R.id.btntrue);
        seekBar=(SeekBar)findViewById(R.id.seekbar);
        sc=(TextView)findViewById(R.id.sorce);
        Intent intent = getIntent();
        mucchoi = intent.getIntExtra("mucchoi", 0);
    }
}

twoPlayer.java (Lớp twoPlayer)

package com.example.freakingmath;

import android.app.*;
import android.content.Intent;
import android.view.*;
import android.os.Bundle;
import android.widget.Button;

public class twoPlayer extends Activity {
    private Button btnBack, btnStart;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            startActivity(new Intent(twoPlayer.this, Typeofplay.class));
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_play_twoplayer);
        btnBack=(Button)findViewById(R.id.back);
        btnStart=(Button)findViewById(R.id.playnow);
        btnStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(twoPlayer.this, playTwoPlayer.class));
            }
        });
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(twoPlayer.this, Typeofplay.class));
            }
        });
    }
}

Typeofplay.java (Lớp Typeofplay)

package com.example.freakingmath;

import android.content.Intent;
import android.os.Bundle;
import android.app.*;
import android.view.*;
import android.widget.Button;

public class Typeofplay extends Activity {
    private Button trueorfalse, back, twoplayer, onePlay;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent intent = new Intent(Typeofplay.this, MainActivity.class);
            startActivity(intent);
        }
        return super.onKeyDown(keyCode, event);
    }
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_typeofplay);
        anhxa();
        trueorfalse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Typeofplay.this, MucChoiToF.class);
                startActivity(intent);
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Typeofplay.this, MainActivity.class);
                startActivity(intent);
            }
        });
        twoplayer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Typeofplay.this, twoPlayer.class));
            }
        });
        onePlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Typeofplay.this, onePlayer.class));
            }
        });
    }
    public void anhxa()
    {
        onePlay=(Button)findViewById(R.id.onePlay);
        trueorfalse=(Button)findViewById(R.id.trueorfalse);
        back=(Button)findViewById(R.id.back);
        twoplayer=(Button)findViewById(R.id.twoplayers);
    }
}

Các file giao diện XML

activity_author.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="@drawable/backgroundauthor"
    tools:context=".MainActivity">
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/duongvientacgia"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_marginBottom="50dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:textColor="#000"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG" />

            <TextView
                android:textColor="#000"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="KHOA CÔNG NGHỆ THÔNG TIN" />
            <TextView
                android:textColor="#000"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="--------o0o--------" />
            <ImageView
                android:layout_marginTop="25dp"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:src="@drawable/logoictu" />
            <TextView
                android:textColor="#000"
                android:layout_marginTop="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:textSize="20dp"
                android:textStyle="bold"
                android:text="BÀI TẬP LỚN" />
            <TextView
                android:textColor="#000"
                android:layout_marginTop="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:textSize="30dp"
                android:textStyle="bold"
                android:text="LẬP TRÌNH ANDROID" />
            <TextView
                android:textColor="#000"
            android:layout_marginTop="30dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:textStyle="bold"
            android:text="Giảng viên: " />
            <TextView
                android:textColor="#000"
                android:layout_marginLeft="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20dp"
                android:text="Đỗ Thị Loan" />
            <TextView
                android:textColor="#000"
                android:layout_marginTop="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20dp"
                android:textStyle="bold"
                android:text="Sinh viên thực hiện:" />
            <TextView
                android:textColor="#000"
            android:layout_marginLeft="30dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:text="Ngô Văn Chiến" />
            <TextView
                android:textColor="#000"
                android:layout_marginLeft="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20dp"
                android:text="Tẩn Cù Chản" />
            <TextView
                android:textColor="#000"
                android:layout_marginLeft="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20dp"
                android:text="Bùi Minh Hiền" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

activity_game_over.xml

<?xml version="1.0" encoding="UTF-8"?>

  <LinearLayout
    tools:context=".GameOver"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="#789"
    android:orientation="vertical"
    android:layout_width="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">
       <TextView
           android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:textSize="25dp"
           android:textColor="#F4A460"
           android:id="@+id/txtScore"/>
      <TextView
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:textSize="25dp"
          android:textColor="#F4A460"
          android:id="@+id/txtHighScore"
          android:layout_marginBottom="5dp"
          android:layout_marginTop="10dp"/>
      <TextView
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:textSize="20dp"
          android:textColor="#524"
          android:id="@+id/lever"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:bufferType="spannable"
        android:fontFamily="@font/shojumaru"
        android:gravity="center"
        android:text="GAME OVER"
        android:textColor="#F03"
        android:textSize="70dp"
        android:typeface="monospace"
        android:visibility="visible"
        tools:visibility="visible" />
      <Button android:layout_height="50dp"
          android:background="@drawable/gocbotron3"
          android:layout_width="260dp"
          android:text="Chơi Lại"
          android:textSize="25dp"
          android:textColor="#fff"
          android:id="@+id/TryAgain"
          android:layout_margin="15dp"/>
      <Button android:layout_height="50dp"
          android:background="@drawable/gocbotron3"
          android:layout_width="260dp"
          android:text="Menu Chính"
          android:textSize="25dp"
          android:textColor="#fff"
          android:id="@+id/mainmenu"
          android:layout_margin="15dp"/>
      <Button
          android:layout_height="50dp"
          android:background="@drawable/gocbotron3"
          android:layout_width="260dp"
          android:text="Trở Về"
          android:textSize="25dp"
          android:textColor="#fff"
          android:id="@+id/back"
          android:layout_margin="15dp"/>
</LinearLayout>

activity_game_over_two_play.xml

<?xml version="1.0" encoding="UTF-8"?>

<LinearLayout
    tools:context=".GameOver"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="#789"
    android:orientation="vertical"
    android:layout_width="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:text="Player 1 vs  Player 2"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:textSize="20dp"
        android:textColor="#524"
        android:id="@+id/player1"/>

    <TextView
        android:id="@+id/scores"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#f88"
        android:textSize="25dp" />

    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:textSize="25dp"
        android:textColor="#F4A460"
        android:id="@+id/txtHighScore"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:bufferType="spannable"
        android:fontFamily="@font/shojumaru"
        android:gravity="center"
        android:text="GAME OVER"
        android:textColor="#F03"
        android:textSize="70dp"
        android:typeface="monospace"
        android:visibility="visible"
        tools:visibility="visible" />
    <Button android:layout_height="50dp"
        android:background="@drawable/gocbotron3"
        android:layout_width="260dp"
        android:text="Chơi Lại"
        android:textSize="25dp"
        android:textColor="#fff"
        android:id="@+id/TryAgain"
        android:layout_margin="15dp"/>
    <Button android:layout_height="50dp"
        android:background="@drawable/gocbotron3"
        android:layout_width="260dp"
        android:text="Menu Chính"
        android:textSize="25dp"
        android:textColor="#fff"
        android:id="@+id/mainmenu"
        android:layout_margin="15dp"/>
    <Button
        android:layout_height="50dp"
        android:background="@drawable/gocbotron3"
        android:layout_width="260dp"
        android:text="Trở Về"
        android:textSize="25dp"
        android:textColor="#fff"
        android:id="@+id/back"
        android:layout_margin="15dp"/>
</LinearLayout>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/images"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:fontFamily="@font/alfa_slab_one"
            android:gravity="center"
            android:text="FREAKING MATH"
            android:textColor="#fff"
            android:textSize="55dp"
            android:textStyle="bold"
            app:fontFamily="@font/alfa_slab_one" />

        <Button
            android:id="@+id/choingay"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron"
            android:layout_margin="10dp"
            android:text="Chơi Ngay"/>

        <Button
            android:id="@+id/highscore"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron"
            android:layout_margin="10dp"
            android:text="Điểm Cao"/>

        <Button
            android:id="@+id/setting"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron"
            android:layout_margin="10dp"
            android:text="Cài Đặt"/>
        <Button
            android:id="@+id/tacgia"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron"
            android:layout_margin="10dp"
            android:text="Tác Giả"/>
    </LinearLayout>

</RelativeLayout>

activity_muc_choi.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/images"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:fontFamily="@font/alfa_slab_one"
            android:gravity="center"
            android:text="MỨC CHƠI"
            android:textColor="#fff"
            android:textSize="55dp"
            android:textStyle="bold"
            app:fontFamily="@font/alfa_slab_one" />
        <Button
            android:id="@+id/easy"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron2"
            android:layout_margin="15dp"
            android:text="DỄ"/>
        <Button
            android:id="@+id/normal"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron2"
            android:layout_margin="15dp"
            android:text="Trung Bình"/>
        <Button
            android:id="@+id/difficult"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron2"
            android:layout_margin="15dp"
            android:text="KHÓ"/>
        <Button
            android:id="@+id/back"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron2"
            android:layout_margin="15dp"
            android:text="Quay Về"/>
    </LinearLayout>

</RelativeLayout>

activity_one_player.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:background="@drawable/backgroundoneplay"
    android:orientation="vertical"
    tools:context=".onePlayer">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#36c">
        <LinearLayout
            android:layout_margin="5dp"
            android:background="@drawable/gocbotronback2"
            android:layout_width="100dp"
            android:layout_height="65dp"
            android:gravity="center">
            <TextView
                android:id="@+id/back"
                android:layout_width="65dp"
                android:layout_height="65dp"
                android:background="@drawable/ic_reply_black_24dp"/>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="vertical"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="219dp"
                    android:padding="10dp"
                    android:weightSum="2">
                    <LinearLayout
                        android:id="@+id/Phepcong"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/maunenphepcong">
                        <TextView
                            android:layout_width="150dp"
                            android:layout_height="150dp"
                            android:background="@drawable/ic_add_black_24dp"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/Pheptru"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/maunenpheptru">
                        <TextView
                            android:layout_width="150dp"
                            android:layout_height="150dp"
                            android:background="@drawable/ic_remove_black_24dp"/>
                    </LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="219dp"
                    android:padding="10dp"
                    android:weightSum="2">
                    <LinearLayout
                        android:id="@+id/Phepnhan"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/maunenphepnhan">
                        <TextView
                            android:layout_width="150dp"
                            android:layout_height="150dp"
                            android:rotation="45"
                            android:background="@drawable/ic_add_black_24dp"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/Phepchia"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/maunenphepchia">
                        <TextView
                            android:layout_width="120dp"
                            android:layout_height="120dp"
                            android:background="@drawable/phepchia"/>
                    </LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="219dp"
                    android:padding="10dp"
                    android:weightSum="2">
                    <LinearLayout
                        android:id="@+id/Phepall"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:weightSum="2"
                        android:orientation="vertical"
                        android:background="@drawable/maunenphep4">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:weightSum="2"
                            android:layout_weight="1">
                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:gravity="center"
                                android:layout_height="match_parent">
                                <TextView
                                    android:layout_width="80dp"
                                    android:layout_height="80dp"
                                    android:background="@drawable/ic_add_black_24dp"/>
                            </LinearLayout>
                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:gravity="center"
                                android:layout_height="match_parent">
                                <TextView
                                    android:layout_width="80dp"
                                    android:layout_height="80dp"
                                    android:background="@drawable/ic_remove_black_24dp"/>
                            </LinearLayout>
                        </LinearLayout>
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">
                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:gravity="center"
                                android:layout_height="match_parent">
                                <TextView
                                    android:rotation="45"
                                    android:layout_width="80dp"
                                    android:layout_height="80dp"
                                    android:background="@drawable/ic_add_black_24dp"/>
                            </LinearLayout>
                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:gravity="center"
                                android:layout_height="match_parent">
                                <TextView
                                    android:layout_width="60dp"
                                    android:layout_height="60dp"
                                    android:background="@drawable/phepchia"/>
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>


</LinearLayout>

activity_play_one_player.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:background="#123"
    android:weightSum="100"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".trueorfalse">
    <LinearLayout
        android:layout_weight="60"
        android:layout_width="match_parent"
        android:weightSum="100"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_height="0dp">

        <SeekBar
            android:id="@+id/seekbar"
            android:layout_width="match_parent"
            android:layout_height="10dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="3dp"
            android:layout_weight="1"
            android:layerType="hardware"
            android:max="39"
            android:progress="39"
            android:scrollbarSize="50dp" />
        <TextView
            android:id="@+id/sorce"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Scores: 0"
            android:textSize="26dp"
            android:gravity="right"
            android:textColor="#fff"
            android:layout_marginRight="10dp"/>
        <TextView
            android:layout_weight="99"
            android:id="@+id/txt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColor="#fff"
            android:textSize="70dp"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/btntrue"
        android:layout_weight="40"
        android:layout_width="match_parent"
        android:weightSum="100"
        android:orientation="vertical"
        android:layout_height="0dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="50"
            android:weightSum="2">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayera"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayerb"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="50"
            android:weightSum="2">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayerc"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayerd"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
        </LinearLayout>

    </LinearLayout>
</LinearLayout>

activity_play_twoplayer.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:orientation="vertical"
    android:gravity="center"
    android:background="@drawable/images"
    android:layout_height="match_parent"
    tools:context=".twoPlayer">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:gravity="center"
        android:text="TWO PLAYER MODE"
        android:textColor="#fff"
        android:textSize="55dp"
        android:textStyle="bold"
        app:fontFamily="@font/alfa_slab_one" />
    <Button
        android:id="@+id/playnow"
        android:textSize="25dp"
        android:layout_width="260dp"
        android:textColor="#fff"
        android:layout_height="50dp"
        android:background="@drawable/gocbotron2"
        android:layout_margin="15dp"
        android:text="Bắt Đầu"/>
    <Button
        android:id="@+id/back"
        android:textSize="25dp"
        android:layout_width="260dp"
        android:textColor="#fff"
        android:layout_height="50dp"
        android:background="@drawable/gocbotron2"
        android:layout_margin="15dp"
        android:text="Quay Về"/>
</LinearLayout>

activity_trueorfalse.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:background="#123"
    android:weightSum="100"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".trueorfalse">
    <LinearLayout
        android:layout_weight="70"
        android:layout_width="match_parent"
        android:weightSum="100"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_height="0dp">

        <SeekBar
            android:id="@+id/seekbar"
            android:layout_width="match_parent"
            android:layout_height="10dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="3dp"
            android:layout_weight="1"
            android:layerType="hardware"
            android:max="39"
            android:progress="39"
            android:scrollbarSize="50dp" />
        <TextView
            android:id="@+id/sorce"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Scores: 0"
            android:textSize="26dp"
            android:gravity="right"
            android:textColor="#fff"
            android:layout_marginRight="10dp"/>
        <TextView
            android:layout_weight="99"
            android:id="@+id/txt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColor="#fff"
            android:textSize="80dp"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/btntrue"
        android:layout_weight="30"
        android:layout_width="match_parent"
        android:weightSum="100"
        android:layout_height="0dp">
        <LinearLayout
            android:layout_weight="50"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:gravity="center"
            android:background="#09f">
            <TextView
                android:layout_width="130dp"
                android:layout_height="130dp"
                android:background="@drawable/ic_check_black_24dp"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/btnFalse"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="50"
            android:background="#fff"
            android:gravity="center">
            <TextView
                android:layout_width="130dp"
                android:layout_height="130dp"
                android:background="@drawable/ic_clear_black_24dp" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

activity_twoplayers.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:orientation="vertical"
    android:weightSum="2"
    android:layout_height="match_parent"
    tools:context=".playTwoPlayer">
    <LinearLayout
        android:background="#123"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:weightSum="100"
        android:orientation="vertical"
        android:layout_weight="1">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:weightSum="2"
            android:orientation="vertical"
            android:layout_weight="45">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="2"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayer1d"
                    android:rotation="180"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
                <Button
                    android:id="@+id/answerplayer1c"
                    android:rotation="180"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="2"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayer1b"
                    android:rotation="180"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
                <Button
                    android:id="@+id/answerplayer1a"
                    android:rotation="180"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="45"
            android:layout_margin="10dp"
            android:gravity="center"
            android:background="@drawable/oluoiscore">

            <TextView
                android:id="@+id/questionplayer1"
                android:rotation="180"
                android:textStyle="bold"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#c90"
                android:textSize="40dp"
                app:fontFamily="@font/aclonica" />
        </LinearLayout>
        <LinearLayout
            android:layout_weight="10"
            android:layout_width="match_parent"
            android:weightSum="100"
            android:layout_height="0dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="20dp"
                android:layout_weight="75">
                <SeekBar
                    android:rotation="180"
                    android:id="@+id/seekbar1"
                    android:layout_width="0dp"
                    android:layout_height="10dp"
                    android:layout_alignParentTop="true"
                    android:layout_marginTop="3dp"
                    android:layout_weight="1"
                    android:layerType="hardware"
                    android:max="39"
                    android:progress="39"
                    android:scrollbarSize="50dp" />
            </LinearLayout>
            <TextView
                android:id="@+id/scores1"
                android:rotation="180"
                android:gravity="center|top"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="25"
                android:text="Scores: 0"
                android:textColor="#fff"
                android:textSize="16dp"/>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:background="#567"
        android:layout_width="match_parent"
        android:layout_height="2dp"/>
    <LinearLayout
        android:background="#123"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:weightSum="100"
        android:orientation="vertical"
        android:layout_weight="1">
        <LinearLayout
            android:layout_weight="10"
            android:layout_width="match_parent"
            android:weightSum="100"
            android:layout_height="0dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="20dp"
                android:layout_weight="75">
                <SeekBar
                    android:id="@+id/seekbar2"
                    android:layout_width="0dp"
                    android:layout_height="10dp"
                    android:layout_alignParentTop="true"
                    android:layout_marginTop="3dp"
                    android:layout_weight="1"
                    android:layerType="hardware"
                    android:max="39"
                    android:progress="39"
                    android:scrollbarSize="50dp" />
            </LinearLayout>
            <TextView
                android:id="@+id/scores2"
                android:gravity="center|top"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="25"
                android:text="Scores: 0"
                android:textColor="#fff"
                android:textSize="16dp"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="45"
            android:layout_margin="10dp"
            android:gravity="center"
            android:background="@drawable/oluoiscore">

            <TextView
                android:id="@+id/questionplayer2"
                android:textStyle="bold"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#c90"
                android:textSize="40dp"
                app:fontFamily="@font/aclonica" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:weightSum="2"
            android:orientation="vertical"
            android:layout_weight="45">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="2"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayer2a"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
                <Button
                    android:id="@+id/answerplayer2b"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="2"
                android:layout_weight="1">
                <Button
                    android:id="@+id/answerplayer2c"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
                <Button
                    android:id="@+id/answerplayer2d"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:textColor="#fff"
                    android:gravity="center"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/oluoi8"
                    android:layout_margin="10dp"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

activity_typeofplay.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/backgound1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:fontFamily="@font/alfa_slab_one"
            android:gravity="center"
            android:text="FREAKING MATH"
            android:textColor="#fff"
            android:textSize="55dp"
            android:textStyle="bold"
            app:fontFamily="@font/alfa_slab_one" />
        <Button
            android:id="@+id/trueorfalse"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron1"
            android:layout_margin="15dp"
            android:text="Đúng hoặc Sai"/>
        <Button
            android:id="@+id/onePlay"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron1"
            android:layout_margin="15dp"
            android:text="Một Người Chơi"/>
        <Button
            android:id="@+id/twoplayers"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron1"
            android:layout_margin="15dp"
            android:text="Hai Người Chơi"/>
        <Button
            android:id="@+id/back"
            android:textSize="25dp"
            android:layout_width="260dp"
            android:textColor="#fff"
            android:layout_height="50dp"
            android:background="@drawable/gocbotron1"
            android:layout_margin="15dp"
            android:text="Quay Về"/>
    </LinearLayout>

</RelativeLayout>

dialog_setting.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="300dp"
    android:orientation="vertical"
    android:background="#789"
    android:layout_height="400dp"
    tools:context=".GameOver">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10dp"
        android:text="Cài Đặt"
        android:textColor="#F03"
        android:textSize="50dp"
        android:fontFamily="@font/shojumaru" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10dp"
        android:text="Tính năng chưa phát triển"
        android:fontFamily="@font/alfa_slab_one"
        android:textColor="#fff"
        android:textSize="50dp" />
</LinearLayout>

highscores.xml

    <LinearLayout

        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/LNback"
        android:layout_below="@id/txtdiemcao"
        android:layout_marginTop="-2dp"
        android:layout_marginBottom="17dp"
        android:orientation="vertical">
        <LinearLayout
            android:layout_marginTop="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_width="match_parent"
            android:weightSum="4"
            android:layout_height="50dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="EASY"
                    android:textStyle="bold"
                    android:textSize="19dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="NORMAL"
                    android:textStyle="bold"
                    android:textSize="19dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="DIFFICULT"
                    android:textStyle="bold"
                    android:textSize="15dp"/>
            </LinearLayout>
        </LinearLayout>


        <LinearLayout
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_width="match_parent"
            android:weightSum="4"
            android:layout_height="50dp">
            <LinearLayout
                android:padding="3dp"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:textStyle="bold"
                    android:gravity="center"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Đúng hoặc sai"
                    android:textSize="15dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView

                    android:textColor="#99CCFF"
                    android:id="@+id/TOFde"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:textColor="#99CCFF"
                    android:id="@+id/TOFtb"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:textColor="#99CCFF"
                    android:id="@+id/TOFkho"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"/>
            </LinearLayout>
        </LinearLayout>


    <LinearLayout
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_width="match_parent"
        android:weightSum="4"
        android:layout_height="250dp">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:weightSum="2"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_weight="1">
                <TextView
                    android:textStyle="bold"
                    android:gravity="center"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Một người chơi"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:weightSum="5"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6"
                    android:layout_weight="1">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="+"
                        android:textSize="25dp"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6"
                    android:layout_weight="1">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="-"
                        android:textSize="30dp"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6"
                    android:layout_weight="1">
                    <TextView
                        android:rotation="45"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="+"
                        android:textSize="25dp"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6"
                    android:layout_weight="1">
                    <TextView
                        android:layout_width="20dp"
                        android:layout_height="20dp"
                        android:background="@drawable/phepchia"
                        android:textSize="25dp"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6"
                    android:layout_weight="1">
                    <TextView
                        android:textStyle="bold"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="General"
                        android:textSize="12dp"/>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="3"
            android:orientation="vertical"
            android:weightSum="5"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="3"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="3"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay21"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay22"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:textColor="#f00"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay23"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="3"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay31"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">

                    <TextView
                        android:id="@+id/oneplay32"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#99CCFF"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay33"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="3"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay41"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay42"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay43"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:weightSum="3"
                android:layout_weight="1">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay51"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay52"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:background="@drawable/gocbotron6">
                    <TextView
                        android:textColor="#99CCFF"
                        android:id="@+id/oneplay53"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp" />
                </LinearLayout>
            </LinearLayout>

        </LinearLayout>
    </LinearLayout>


        <LinearLayout
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_width="match_parent"
            android:weightSum="4"
            android:layout_height="50dp">
            <LinearLayout
                android:padding="3dp"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:textStyle="bold"
                    android:gravity="center"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Hai người chơi"
                    android:textSize="15dp"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="3"
                android:gravity="center"
                android:background="@drawable/gocbotron6"
                android:layout_height="50dp">
                <TextView
                    android:textColor="#99CCFF"
                    android:id="@+id/hainguoichoi"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"/>
            </LinearLayout>
        </LinearLayout>




    </LinearLayout>
    <LinearLayout
        android:id="@+id/LNback"
        android:layout_width="match_parent"
        android:layout_marginBottom="20dp"
        android:layout_alignParentBottom="true"
        android:gravity="center"
        android:layout_height="wrap_content">
        <Button
            android:textStyle="bold"
            android:id="@+id/back"
            android:textColor="#fff"
            android:textSize="18dp"
            android:background="@drawable/gocbotronback"
            android:layout_marginLeft="15dp"
            android:layout_width="120dp"
            android:layout_height="50dp"
            android:text="Quay về"/>
    </LinearLayout>
</RelativeLayout>
XÊM THÊM
Tỏ tình Crush bằng code C/C++ – I LOVE YOU ngôn ngữ C/C++
Lập trình game Cờ Caro trên C/C++ màn hình Console(Demo Game)
Lập trình game Rắn săn mồi trên C/C++ màn hình Console(Demo Snake)
Xây dựng demo Code Vượt vật cản trên màn hình Console C/C++
Lập trình Demo Ai Là Triệu Phú trên Graphics C/C++
0 0 Phiếu bình chọn
Xếp hạng bài viết
BÀI VIẾT LIÊN QUAN
Đăng ký nhận thông báo
Thông báo email khi
guest
0 Bình luận
Không thể gửi email
Phản hồi nội tuyến

NÊN ĐỌC THÊM

Bạn muốn tìm kiếm gì?

Dịch vụ code thuê

TUICOCACH.COM NHẬN ĐẶT TEXTLINK, BANNER, GP
0
Giáo sư! có thể ném gạch bên dưới nhé!x