앱을 개발하다보면 페이지를 이동할 때가 많은데,
안하다보면 또 까먹는다... 그렇게 많이 사용했음에도 불구하고...
아마도 너무 습관처럼 사용해서 까먹게 되는 것 같다.
페이지의 이동에서는 Intent 메소드를 사용하면 된다.
package com.example.uprotest03;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button title_settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 버튼 액티비티 선언
title_settings = findViewById(R.id.title_settings);
// 설정
title_settings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentSetting = new Intent(getApplicationContext(), Settings.class);
startActivity(intentSetting);
}
});
}
}
이런식으로 보통 클릭 이벤트에 섞어서 많이 쓰는 편이다.
만약 클릭 이벤트에 사용하지 않고, MainActivity에서 바로 Intent를 사용해버리면
앱을 시작하자마자 설정해준 화면으로 넘어가버린다ㅋㅋ
'프로그래밍 > Android' 카테고리의 다른 글
Androdi Programming : 화면 전환 시 애니메이션 적용하기 (0) | 2020.04.28 |
---|---|
Android Programming : Intent 사용으로 페이지가 중복 겹칠 경우 (0) | 2020.04.24 |
Androdi Programming : 타이틀바 제거하기 (0) | 2020.04.22 |
Androdi Programming : 안드로이드 스튜디오 이전버전 설치하기 (2) | 2020.04.22 |
Android Programming+MySQL+PHP 연동 (2020.02.12~2020.02.17) (0) | 2020.02.21 |