[Android] 뒤로가기 버튼 두 번 눌렀을 때 앱 종료하기

By | 12월 29, 2020

인터넷에 널린 유사한 글들을 살짝 수정함.   * 뒤로가기 핸들러 정의 package and.bruce.com.handler; import android.app.Activity; import android.content.pm.ApplicationInfo; import android.support.v4.app.ActivityCompat; import android.widget.Toast; import and.bruce.com.App; /** * 뒤로가기 버튼을 두 번 눌렀을 때 앱을 종료하게 하는 핸들러 */ public class BackPressCloseHandler { private long backKeyPressedTime = 0; private static final long checkInterval = 2000; private Toast toast;… Read More »

[Android] 액션바에 뒤로가기 화살표 표시 및 뒤로가기 기능 추가

By | 12월 29, 2020

*  정의부 (MainActivity > Navigation Drawer 생성) protected void onCreate(Bundle savedInstanceState) { … Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // actionbar 좌측에 뒤로가기 화살표 표시 DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(drawerToggle); drawerToggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); … }   *  정의부 (MainActivity > 뒤로가기… Read More »

[Android] ScrollView 안에 ConstraintLayout 을 넣고, 그 안에 TableLayout을 넣은 샘플

By | 12월 29, 2020

  <ScrollView 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_height=”fill_parent” android:layout_width=”fill_parent” > <android.support.constraint.ConstraintLayout 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:tag=”buttonParent” android:layout_width=”match_parent” android:layout_height=”match_parent” tools:layout_editor_absoluteY=”81dp” tools:layout_editor_absoluteX=”0dp”> <!– ConstraintLayout 안에 TableLayout을 넣어 보았다 –> <TableLayout android:id=”@+id/tableLayout1″ android:layout_width=”0dp” android:layout_height=”wrap_content” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toTopOf=”parent” android:layout_marginTop=”10dp”> <TableRow android:id=”@+id/tableRow1″ android:layout_width=”match_parent” android:layout_height=”match_parent” android:padding=”5dip”> <TextView style=”@style/FormLabel02″ android:layout_width=”0dp” android:layout_height=”match_parent” android:layout_gravity=”center_vertical” android:layout_weight=”3″ android:gravity=”center_vertical|end” android:text=”호출 서버 : ” /> <RadioGroup xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/rgSvr” android:layout_width=”0dp” android:layout_height=”wrap_content” android:orientation=”horizontal”… Read More »

[Android] 텍스트 파일(컴파일되지 않은)을 읽어서 String 으로 변환하기

By | 12월 29, 2020

InputStream in = getResources().openRawResource(R.raw.oss_license); StringBuilder sb = new StringBuilder(); Scanner sc = new Scanner(in); while (sc.hasNextLine()) { sb.append(sc.nextLine()).append(“\n”); } sc.close(); String contents = sb.toString();   * /res/raw 디렉토리에 있는 파일은 컴파일되지 않는다고 해서 raw 디렉토리를 별도로 생성하여 oss_license.txt 파일을 그 안에 넣어 둠. * /res/raw 디렉토리 안에 있는 파일을 읽을 수 있는 openRawResource() 메서드를 Android… Read More »

[git] intellij 에서 빈 github repository 와 연동하기

By | 12월 29, 2020

※ 소스는 로컬에 있고 github에는 빈 repository 가 있을 경우 github 계정 셋팅은 이미 완료되어 있다는 가정. 프로젝트 우클릭 > Manage Remotes 에서 git full url 을 등록한다. 프로젝트 우클릭 > git > add 프로젝트 우클릭 > git > push

“이 컴퓨터에 마지막으로 연결한 usb 장치가 오작동했으며 windows에서 장치를 인식할 수 없습니다” 상황시 해결 경험

By | 12월 25, 2020

제어판 > 장치관리자 에 보면 ‘알 수 없는 장치(장치 설명자 요청 실패)’ 라고 느낌표 표시된 장치가 있을 건데, 해당 장치를 장치관리자에서 제거한다. 제어판 > 장치 및 프린터 에 보면 역시 해당 장치가 있을텐데 제거해 준다. 장치 새로고침이든 뭐든 해서 refresh 를 해 보자.