전체 글(123)
-
RecyclerView 기본 사용법
0. 기본적인 UserItem.class와 item_user.xml 생성public class UserItem { int userId; int id; String title; String body; public UserItem(int userId, int id, String title, String body) { this.userId = userId; this.id = id; this.title = title; this.body = body; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public int getId() { return id; } public voi..
2018.11.25 -
Zxing QR code Scan 세로모드portrait
예전엔 기능 지원을 안했는지 CaptureActivity 상속받아서 커스텀 하는 방법만 있었던거 같은데,이 글 작성기준 zxing 3.6.0에서는 orientation을 portrait하는 기능을 지원한다. 출처 : https://github.com/journeyapps/zxing-android-embedded#changing-the-orientation 여기에 잘 나와있고, 방법은...AndroidManifest.xml 해당 zxing 불러오는 ActivityIntentIntegrator integrator = new IntentIntegrator(this); integrator.setOrientationLocked(false); integrator.initiateScan();가로모드로 불러오는것까지 ..
2018.11.17 -
Unable to start activity ComponentInfo
java.lang.RuntimeException: Unable to start activity ComponentInfo 의 orientation 설정 체크를 오타로 로 썼는지 체크manifest 오타나 없는 activity추가했는지 여부 체크 오타로 문제가 생기는 경우가 있고,버그로 문제가 생기는 경우가 있는듯하니,잘 실행되던 프로젝트면 clean 후 실행, 프로젝트 다시 불러와서 실행, 혹은 android studio 재실행 후 실행도 해보길 바람.
2018.11.17 -
소수찾기
n까지의 정수중 소수의 개수 구하기 생각나는대로 코딩 123456789101112def solution(n): answer = 0 for i in range(2,n+1): count = 0 for j in range(2,i) : if i%j==0: count+=1 break if count ==0 : answer+=1 return answercs 효율성 엄청 떨어짐. 공부하고 만든 코드 12345678910111213141516171819202122def solution(n): answer = 0 for i in range(1, n+1) : count = 0 if i
2018.11.13 -
문자열 내림차순 정렬
임의의 문자열을 받아서 z-aZ-A순으로 정렬.ex) "sdfZga" => "sgfdaZ" Code 12def solution(s): return "".join(sorted(s, reverse=True))cs 문자열 하나씩 불러올 필요 없이, sorted()로 바로 정렬 가능.sorted()에 reverse=False가 기본값이고, reverse=True를 주면 역순 정렬.join()
2018.11.12 -
문자열 내의 숫자 여부 확인
문자열 s의 길이가 4혹은 6이고, 숫자로만 구성되있는지 확인해주는 함수, solution을 완성하세요.예를들어 s가 a234이면 False를 리턴하고 1234라면 True를 리턴하면 됩니다. 생각나는대로 코딩 1234567891011import redef solution(s): answer = True if len(s) not in [4,6]: return False if re.findall('[a-zA-Z]',s) != [] : answer = False return answercs 더 나은 방법 12def solution(s): return s.isdigit() and len(s) in [4,6]cs .isdigit() 함수는 문자열이 숫자만 있으면 True, 문자가 섞여있으면 False를 반환 한..
2018.11.05