본문 바로가기

Android/Knowhow

배열 객체는 가급적 쓰지말자 List에 여러 문자열을 추가할 때, 배열 객체를 사용하면 안좋다. 다루기 어렵다.(정확한 이유는 아직 모름. 이펙티브 자바에도 내용 없음) 123456789 String[] categories = { getString(R.string.category_korea), getString(R.string.category_china), getString(R.string.category_japan) }; List list = new ArrayList(); list.addAll(Arrays.asList(categories)); Colored by Color Scriptercs List 객체로 만들어서 복사하거나 array xml을 이용하자. 12345678 @string/category_korea @string/c.. 더보기
[Android] input String quotes in BuildConfig I clone some project. To run app, must input my API KEY instead of placeholder. In above file, I input my API KEY instead of "MyOpenWeatherMapApiKey".But BuildConfig.java linked with app/build.gradle doesn't create quotes(") and occurs error. app/build.gradle 12345678910111213141516171819202122232425262728apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "2.. 더보기
안드로이드 스튜디오 cannot resolve symbol r :: 강력한 해결법 File > Invalidate Caches / Restart > Invalidae and Restart Clean이랑 Rebuild 해봐도 에러 해결이 안된다.하지만 Invalidate Caches 한 방이면 해결이 된다. If you see this error after moving java files or directories to other locations, then you can guarantee that Android Studio has gotten confused. And guess what? undo-ing those actions doesn't fix the problem.So you try a clean, but that doesn't work.And restarting doesn't.. 더보기
[JAVA] input char array to special chars /* 역슬래시를 활용할 것 */ char special[] = { '~', '`', '!', '@', '#', '$', '%', '&', '^', '*', '(', ')', '-', '_', '=', '+', '|', '[', ']', '{', '}', ';', ':', '\'', '"', ',', '.', '', '\\', '/', '?' }; 더보기
[color] Hex Opacity Values 100% — FF95% — F290% — E685% — D980% — CC75% — BF70% — B365% — A660% — 9955% — 8C50% — 8045% — 7340% — 6635% — 5930% — 4D25% — 4020% — 3315% — 2610% — 1A5% — 0D0% — 00 #FF000000 은 100% 블랙#80000000 은 50% 블랙 ㅇㅋㄷㅋ? 더보기
Adapter 실제 데이터를 가지고 있지 않는게 편할때가 많다. Adapter라는 의미 자체가 "연결"을 해준다는 것이지,자체적으로 데이터를 가지고 있다는게 아니닷! 그래서 Adapter를 컨트롤러 레벨로 인식하기 보다는 모델이라고 보는것이 자연스럽닷! 자바는 포인터 대신 레퍼런스 타입이 있다.new 연산자로 힙에 생성시키기때문에 별도의 삭제를 해야 메모리에서 해제된다.123Phone myphone;myphone = new Phone();myphone.manufacturer = "apple";cs Answer by edan 더보기
변수 선언할 때, 스케일 설정을 어떻게 할까? 난 지역변수로만 사용되어도 일단 멤버변수로 선언하는 습관이 있었다.(넓게 보고싶었던 의미가 담겨있다.) 그런데 실무에서는멤버변수로 선언되고 사용되지않은 메모리 누수까지도 생각해야 한다. 따라서 우선 지역변수로 선언하자.그리고나서 다른 메소드나 클래스에서도 사용해야하는 변수일 경우에 멤버변수로 확장하자. 더보기