EditText 위젯을 읽기전용(read only)로 설정하고자 했는데, XML상 속성 "android:editable", 폐기예정이므로 몇가지 방법들을 찾아봤다.
XML에서 설정
"android:inputType" 속성을 제거하고, "android:focusable" 속성값을 "false"로 한다.
<EditText
android:id="@+id/editWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight = "1"
android:padding="8dp"
android:background="?attr/colorPrimaryDark"
android:textSize="30sp"
android:focusable="false"
android:text="Word"/>
코드상에서 설정
setInputType 함수를 사용한다. 매개값으로 InputType.TYPE_NULL을 넘기면 된다.
EditText editWord = (EditText)findViewById(R.id.editWord);
editWord.setInputType(InputType.TYPE_NULL);
추가팁 (나만 몰랐던)
"LinearLayout" 에서 어떤 위젯이 남은 공간 채우도록 만들기 위해 구글링된 여러 방식들을 시도해봤다. 오로지 "android:layout_weight"값을 "1"로 설정하는 것 만이 제대로 동작했고, 다른 것들은 사용할 필요가 없었다.
'Trouble Shooting' 카테고리의 다른 글
Proxy 설정 (apt, wget) (0) | 2018.01.10 |
---|---|
안드로이드 뒤로가기 버튼(백버튼) 보이기 및 가리기 (0) | 2017.10.18 |
[GIT 정리] 이미 commit/push된 파일을 .gitignore에 등록하기 (0) | 2017.08.30 |
[GIT 정리] 여러 조회 방법 및 충돌 파일 간단 처리 (0) | 2017.08.26 |
안드로이드 시뮬레이터, root권한 없이 SQLite DB 파일 접근 (0) | 2017.08.14 |