Author Archives: itpsolver

[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 »

이클립스에서 Ctrl + H 로 파일 찾기(search)를 한 후 찾은 파일을 클릭할 때마다, 에디터에서 새 탭을 띄우는 게 아니라 기존 창이 덮어씌워지는 문제 해결

By | 12월 15, 2017

먼저 찾아 놓은 창들이 계속 사라져서 짜증났었는데, 설정에서 변경 가능한 것을 확인했다.   Eclipse > Window > Preferences > General > Search 에서     Reuse editors to show matches 의 체크박스를 해제 하면 된다.    

이클립스에서 메이븐(Maven) 사용시 인증서 에러로 인해 artifact 들이 다운로드 되지 않을 경우, 미러(mirror)서버로 우회한 케이스

By | 8월 16, 2017

(1) 회사 인터넷망에서 이클립스-메이븐 사용을 하려는데 아래와 같은 에러가 발생하였다. Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target   (2) 검색을 해 보니, 회사 인증서 같은 것을 jdk에 import 해야 한다고 하는데, 잘 모르겠고 너무나 귀찮은 작업…   (3) 그래서… Read More »

[펌글] 해밍 거리(Hamming Distance)

By | 8월 16, 2017

– 출처: http://blog.naver.com/yagd_mirage/10042944461 –   정보 이론에서, 해밍 거리(해밍距離 , Hamming distance)는 같은 길이를 가진 두 개의 문자열에서 같은 위치에 있지만 서로 다른 문자의 개수이다. 즉, 한 문자열을 다른 문자열로 바꾸기 위해서 몇글자를 바꾸어야 하는지를 나타낸 것이다. 리처드 해밍이 제안했다. 컴퓨터 통신등에서 문자열의 전송 도중 몇 글자에서 오류가 났나를 측정하는 방법 중 하나이다. ‘1011101’과 ‘1001001’사이의 해밍 거리는 2이다. (1011101,… 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] 액션바에 뒤로가기 화살표 표시 및 뒤로가기 기능 추가

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] 뒤로가기 버튼 두 번 눌렀을 때 앱 종료하기

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] View(혹은 Layout) 내의 요소(ex: EditText)들을 순회(loop)하면서 각 요소(element)의 id를 key로 하여 SharedPreferences 에 값을 저장하는 샘플코드

By | 12월 29, 2020

* 정의부 /** * view 하위의 특정 TableLayout의 TableRow를 순회하면서 EditText를 찾고, * 각 EditText의 id 문자열로 SharedPreferences(혹은 Constants)를 조회한 결과값을 EditText에 채워 넣는다. * * @param rootView * @param tableLayoutId */ public static void fillSavedDataToForm(View rootView, int tableLayoutId) { TableLayout tableLayout = (TableLayout) rootView.findViewById(tableLayoutId); TableRow tableRow; View tmpView; EditText et; String id, key, val;… Read More »