| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- 생성자
- 숫자 형식
- 함수
- 예외
- SQL
- 우아한테크
- Doit입문SQL
- 페이지분석
- 웹브라우저 수용도
- 데이터베이스
- 함수 선언
- html
- 자바 예외
- 키-값 데이터베이스
- dbms
- R1C3
- 웹 브라우저 전쟁
- 자바 오류
- 크롤링
- 배열 예제
- DoitSQL
- 배열 3요소
- DoitSQL입문
- 크롤링 오류
- 자바
- 예제
- DoIt
- HTML역사
- 숫자형식오류
- SQL입문
													Archives
													
											
												
												- Today
- Total
반응형
    
    
    
  | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- 생성자
- 숫자 형식
- 함수
- 예외
- SQL
- 우아한테크
- Doit입문SQL
- 페이지분석
- 웹브라우저 수용도
- 데이터베이스
- 함수 선언
- html
- 자바 예외
- 키-값 데이터베이스
- dbms
- R1C3
- 웹 브라우저 전쟁
- 자바 오류
- 크롤링
- 배열 예제
- DoitSQL
- 배열 3요소
- DoitSQL입문
- 크롤링 오류
- 자바
- 예제
- DoIt
- HTML역사
- 숫자형식오류
- SQL입문
													Archives
													
											
												
												- Today
- Total
프로그래밍
[Do it! 안드로이드 앱] 자바) 세 개 이상의 화면 만들어 전환하기 본문
728x90
    
    
  반응형
    
    
    
  도전과제 08
실행화면

디자인



프로젝트 설명
앱에서 사용될 수 있는 여러 화면을 구성하고 각 화면을 전환하면서 토스트로 메세지를 띄워주도록 한다
1. 로그인 화면과 메뉴 화면 그리고 세 개의 서브 화면(고객 관리 화면, 매출 관리 화면, 상품 관리 화면)을 각각 액티비티로 만듭니다. 
2. 로그인 화면에는 두 개의 입력상자와 하나의 버튼이 들어가도록 합니다. 
3. 메뉴 화면에는 세 개의 버튼이 들어가도록 하고 각각 '고객 관리, '매출 관리', '상품 관리' 라는 이름으로 표시합니다. 
4. 로그인 화면의 [로그인] 버튼을 누르면 메뉴 화면으로 이동합니다. 만약 사용자 이름이나 비밀번호가 입력되어 있지 않은 상태에서 [로그인] 버튼을 누르면 토스트로 입력하라는 메시지를 보여주고 대기합니다. 
5. 메뉴 화면의 버튼 중에서 하나를 누르면 해당 서브 화면으로 이동합니다. 메뉴 화면에 있는 [로그인] 버튼을 누르면 로그인 화면으로 이동하고 각 서브 화면에 있는 [메뉴] 버튼을 누르면 메뉴 화면으로 이동합니다
activity_mainxml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:padding="50dp"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <TextView
        android:text="로그인하기"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:textSize="30dp"
        android:gravity="center_horizontal"/>
    <EditText
        android:id="@+id/EdtLogin"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:hint="아이디"
        android:layout_marginTop="50dp"
        />
    <EditText
        android:id="@+id/EdtPass"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:hint="비밀번호"
        android:inputType="textPassword"
        android:layout_marginTop="10dp"
        android:layout_below="@id/EdtLogin"/>
    <Button
        android:id="@+id/BtnLogin"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_below="@id/EdtPass"
        android:layout_marginLeft="210dp"
        android:layout_marginTop="-98dp"
        android:text="로그인" />
</RelativeLayout>MainActivity.java
package com.sample.doitmission_08;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
    EditText edtLogin, edtPass;
    Button btnLogin;
    String id, pass;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnLogin = findViewById(R.id.BtnLogin);
        edtLogin = findViewById(R.id.EdtLogin);
        edtPass = findViewById(R.id.EdtPass);
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                id = String.valueOf(edtLogin.getText());
                pass = String.valueOf(edtPass.getText());
                if (id == null && pass == null) {
                    Toast.makeText(getApplicationContext(), "아이디와 패스워드를 입력해주세요", Toast.LENGTH_SHORT).show();
                }
                else {
                    Intent intent = new Intent(MainActivity.this, MenuActivity.class);
                    startActivity(intent);
                }
            }
        });
    }
}activity_menu.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"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MenuActivity"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="60dp"
        android:text="메인메뉴" />
    <Button
        android:id="@+id/Btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"
        android:textSize="30dp"
        android:text="고객 관리"/>
    <Button
        android:id="@+id/Btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp"
        android:textSize="30dp"
        android:text="매출 관리"/>
    <Button
        android:id="@+id/Btn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textSize="30dp"
        android:text="상품 관리"/>
</LinearLayout>MenuActivity.java
package com.sample.doitmission_08;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MenuActivity extends AppCompatActivity {
    Button btn1, btn2, btn3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);
        btn1 = findViewById(R.id.Btn1);
        btn2 = findViewById(R.id.Btn2);
        btn3 = findViewById(R.id.Btn3);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MenuActivity.this, CustomerActivity.class);
                startActivity(intent);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MenuActivity.this, SaleActivity.class);
                startActivity(intent);
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MenuActivity.this, ProductActivity.class);
                startActivity(intent);
            }
        });
    }
}activity_customerxml
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".CustomerActivity"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="60dp"
        android:text="고객 관리" />
    <Button
        android:id="@+id/Btn1_1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"
        android:textSize="30dp"
        android:text="메뉴로"/>
    <Button
        android:id="@+id/Btn1_2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp"
        android:textSize="30dp"
        android:text="로그인으로"/>
</LinearLayout>CustomerActivity.java
package com.sample.doitmission_08;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
    public class CustomerActivity extends AppCompatActivity {
        Button btn1_1, btn1_2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_customer);
            btn1_1 = findViewById(R.id.Btn1_1);
            btn1_2 = findViewById(R.id.Btn1_2);
            btn1_1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(CustomerActivity.this, MenuActivity.class);
                    startActivity(intent);
                }
            });
            btn1_2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(CustomerActivity.this, MainActivity.class);
                    startActivity(intent);
                }
            });
    }
}activity_salexml
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".SaleActivity"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="60dp"
        android:text="매출 관리" />
    <Button
        android:id="@+id/Btn2_1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"
        android:textSize="30dp"
        android:text="메뉴로"/>
    <Button
        android:id="@+id/Btn2_2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp"
        android:textSize="30dp"
        android:text="로그인으로"/>
</LinearLayout>SaleActivity.java
package com.sample.doitmission_08;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class SaleActivity extends AppCompatActivity {
    Button btn2_1, btn2_2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sale);
        btn2_1 = findViewById(R.id.Btn2_1);
        btn2_2 = findViewById(R.id.Btn2_2);
        btn2_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SaleActivity.this, MenuActivity.class);
                startActivity(intent);
            }
        });
        btn2_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SaleActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }
}activity_productxml
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ProductActivity"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="60dp"
        android:text="상품 관리" />
    <Button
        android:id="@+id/Btn3_1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"
        android:textSize="30dp"
        android:text="메뉴로"/>
    <Button
        android:id="@+id/Btn3_2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp"
        android:textSize="30dp"
        android:text="로그인으로"/>
</LinearLayout>ProductActivity.java
package com.sample.doitmission_08;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class ProductActivity extends AppCompatActivity {
    Button btn3_1, btn3_2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product);
        btn3_1 = findViewById(R.id.Btn3_1);
        btn3_2 = findViewById(R.id.Btn3_2);
        btn3_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ProductActivity.this, MenuActivity.class);
                startActivity(intent);
            }
        });
        btn3_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ProductActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }
}
Manifest.xml
<activity android:name=".MenuActivity"/>
<activity android:name=".CustomerActivity"/>
<activity android:name=".SaleActivity"/>
<activity android:name=".ProductActivity"/>
728x90
    
    
  반응형
    
    
    
  '안드로이드 > Do it! 안드로이드 앱프로그래밍' 카테고리의 다른 글
| [Do it! 안드로이드 앱] 자바) 프래그먼트 이용하여 이미지뷰어 만들기 (0) | 2022.05.23 | 
|---|---|
| [Do it! 안드로이드 앱] 자바) 버튼으로 프래그먼트 교체하기 (0) | 2022.05.23 | 
| [Do it! 안드로이드 앱] 자바) 로그인 화면과 메뉴 화면 전환하기 (2) | 2022.05.20 | 
| [Do it! 안드로이드 앱] 자바) 두 종류의 버튼 모양 만들기 (0) | 2022.05.18 | 
| [Do it! 안드로이드 앱] 자바) SMS 입력 화면 만들고 글자의 수 표시하기 (0) | 2022.05.16 | 
			  Comments
			
		
	
               
           
					
					
					
					
					
					
				 
                
                
                
                
                
                
                
                                                
                
                
                
	 
								 
								 
								