반응형

1. Toast Message : 안드로이드 팝업 메세지. ( 디버깅용으로 많이 사용 )

 

Context context = getApplicationContext();  // Context 
CharSequence text = "Hello toast!";  // 표시되는 메세지 
int duration = Toast.LENGTH_SHORT;  // 화면이 표시되는 주기 

Toast toast = Toast.makeText(context, text, duration);  // Toast 객체 정의
toast.show();  // show 

 

Default : 메시지 알림은 화면 하단에 표시되며 가로로 가운데

Gravity Method : 상수, x-좌표 오프셋 및 y-좌표 오프셋의 세 가지 매개변수를 사용.

 

예를 들어, 토스트 메시지를 왼쪽 상단에 표시하려면 Gravity를 다음과 같이 설정하면 됩니다.

 

toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);

 

 

 

 

 

2. Logcat : 앱과 관련된 로그 출력. ( System.out.print 용처럼 사용,  디버깅용)

 

 

private static final String TAG = "MyActivity";
...
String message = "Hello";
Log.d(TAG, message);

 

 

 

developer.android.com/guide/topics/ui/notifiers/toasts

 

토스트 메시지 개요  |  Android 개발자  |  Android Developers

토스트 메시지는 작은 팝업으로 작업에 관한 간단한 피드백을 제공합니다. 메시지에 필요한 공간만 차지하며 진행 중인 활동은 그대로 표시되고 상호작용도 유지됩니다. 토스트 메시지는 시간

developer.android.com

developer.android.com/studio/debug/am-logcat?hl=ko

 

Logcat을 이용한 로그 작성 및 보기  |  Android 개발자  |  Android Developers

Android 스튜디오에서 Logcat 창에 시스템 메시지를 표시하는 방법을 알아보세요.

developer.android.com

 

728x90
반응형

+ Recent posts