라벨이 프로그래밍(JAVA)인 게시물 표시

안드로이드 앱 자바(java) 기본형 카메라

기본형 카메라 예시 코드입니다.   res/layout/activity_main.xml < ? 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" > < SurfaceView android : id = "@+id/surfaceView" android : layout_width = "match_parent" android : layout_height = "match_parent" / > < Button android : id = "@+id/captureButton" android : layout_width = "wrap_content" android : layout_height = "wrap_content" android : layout_centerHorizontal = "true" android : layout_alignParentBottom = "true" android : text = "사진 찍기" / > < / RelativeLayout > MainActivity.java import android . app . Activity ; import and...

SharedPreferences (데이터를 기억하는 함수)

  데이터를 저장하여 앱을 완전 종료하여도 기억할 수 있는 코드입니다 ​ SharedPreferences 초기화 ​ import android . content . Context ; import android . content . SharedPreferences ; public class MyPreferences { private static final String PREFERENCES_NAME = "MyAppPreferences" ; private SharedPreferences preferences ; public MyPreferences ( Context context ) { preferences = context . getSharedPreferences ( PREFERENCES_NAME , Context . MODE_PRIVATE ) ; } public void saveData ( String key, String value ) { SharedPreferences . Editor editor = preferences . edit ( ) ; editor . putString ( key , value ) ; editor . apply ( ) ; } public String loadData ( String key, String defaultValue ) { return preferences . getString ( key , defaultValue ) ; } } 액티비티에서 사용 import android . app . Activity ; import android . os . Bundle ; import android . widget . EditText ; import android . widget . Toast ; pu...