activity_main.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"
tools:context =".MainActivity"
android:background ="@drawable/soccer" >
<androidx.appcompat.widget.AppCompatButton
android:id ="@+id/button1"
android:background ="#F44336"
android:layout_width ="300dp"
android:layout_height ="wrap_content"
android:layout_gravity ="center"
android:layout_marginTop ="100dp"
android:text ="INTRODUCTION"
android:textSize ="20dp"
android:textStyle ="bold"
android:layout_marginBottom ="5dp" />
<androidx.appcompat.widget.AppCompatButton
android:id ="@+id/button2"
android:layout_width ="300dp"
android:layout_height ="wrap_content"
android:layout_gravity ="center"
android:background ="#F44336"
android:text ="SETTINGS"
android:textSize ="20dp"
android:textStyle ="bold"
android:layout_marginBottom ="5dp"
/>
<androidx.appcompat.widget.AppCompatButton
android:id ="@+id/button3"
android:layout_width ="300dp"
android:layout_height ="wrap_content"
android:layout_gravity ="center"
android:text ="START"
android:textSize ="20dp"
android:textStyle ="bold"
android:background ="#F44336" />
</LinearLayout >
MainActivity.java
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
Button button1, button2, button3;
@Override
protected void onCreate (Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick (View view) {
Intent intent = new Intent(MainActivity.this , Introduction.class);
startActivity(intent);
}
});
button2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick (View view) {
Intent intent = new Intent(MainActivity.this , Settings.class);
startActivity(intent);
}
});
button3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick (View view) {
Intent intent = new Intent(MainActivity.this , Start.class);
startActivity(intent);
}
});
}
}
introduction.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:background ="@drawable/son"
android:orientation ="vertical" >
<TextView
android:id ="@+id/textView1"
android:layout_width ="match_parent"
android:layout_height ="wrap_content"
android:text ="손흥민은 대한민국 레전드이다."
android:textSize ="30dp"
android:textColor ="@color/white" />
<Button
android:id ="@+id/button1"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="home"
android:layout_marginTop ="500dp"
android:layout_gravity ="center_horizontal" />
</LinearLayout >
settings.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:orientation ="vertical" >
<EditText
android:id ="@+id/editTextText"
android:layout_width ="match_parent"
android:layout_height ="50dp"
android:ems ="10"
android:inputType ="text"
android:text ="Difficulties" />
<EditText
android:id ="@+id/editTextText2"
android:layout_width ="match_parent"
android:layout_height ="50dp"
android:ems ="10"
android:inputType ="text"
android:text ="Players" />
<Button
android:id ="@+id/button1"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="home"
android:layout_marginTop ="400dp"
android:layout_gravity ="center_horizontal" />
</LinearLayout >
start.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:background ="@drawable/startson"
android:orientation ="vertical" >
<Button
android:id ="@+id/button1"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="home"
android:layout_marginTop ="500dp"
android:layout_gravity ="center_horizontal" />
</LinearLayout >
JAVA
package com.example.myapplication;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class Settings extends AppCompatActivity {
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 메인을 제외한 나머지는 버튼마다 XML 제목에 맞는걸로 바꿔주면됩니다.
setContentView(R.layout.settings);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android ="http://schemas.android.com/apk/res/android"
xmlns:tools ="http://schemas.android.com/tools" >
<application
android:allowBackup ="true"
android:dataExtractionRules ="@xml/data_extraction_rules"
android:fullBackupContent ="@xml/backup_rules"
android:icon ="@mipmap/ic_launcher"
android:label ="@string/app_name"
android:roundIcon ="@mipmap/ic_launcher_round"
android:supportsRtl ="true"
android:theme ="@style/Theme.MyApplication"
tools:targetApi ="31" >
<activity
android:name =".MainActivity"
android:exported ="true" >
<intent-filter >
<action android:name ="android.intent.action.MAIN" />
<category android:name ="android.intent.category.LAUNCHER" />
</intent-filter >
</activity >
// 자바 클래스명 넣으면 됨
<activity android:name =".Introduction" android:label ="Introduction" > </activity >
<activity android:name =".Settings" android:label ="Settings" > </activity >
<activity android:name =".Start" android:label ="Start" > </activity >
</application >
</manifest >
버튼을 클릭하면 다른 xml 화면이 뜬다.
공유하기
URL 복사 카카오톡 공유 페이스북 공유 엑스 공유