유디의 공간정보·개발일기

3. 0709_ Null check와 ArrayList를 적용한 버튼 활성화 본문

JAVA + Android Studio

3. 0709_ Null check와 ArrayList를 적용한 버튼 활성화

55yudi 2021. 10. 23. 23:27

- Binding 설정변경 하기

 

- 배경에 이미지 넣기

  * 이미지 파일 복사해서 drawble 폴더에 붙여넣기

  * component tree - constraint layout 클릭 - 설정창 background 네모 클릭 - 이미지 선택

 

- '확인'버튼을 누르면 배경 사진이 뜨게 하기

  ImageView id : output2

binding.output2.setImageResource(R.drawble.sky);

- 글자를 숫자형으로 변환

int int1 = Integer.parseInt(myInput1);

- 숫자를 글자형으로 변환

String string1 = String.valueof(int1);

 


- 버튼 누르기 전(처음 화면)에 이미지를 아무것도 보이지 않게 하려면

  xml --> ImageView 위젯 선택 - 속성창 Visibility - invisible로 설정

  java --> imageView.setVisibility(view.visible);

 

- '다음' 버튼을 누르면 사람이미지가 뜨도록 하기

imageView. setImageResource(R.drawble.person);

 

~ onButton ~
  if (person01 != null) {
    person01.walk(10);
  }
  
  
~ onButton1 ~
  if (person01 != null) {
    person01.run(10);
  }

imageView.setVisibility(view.VISIBLE);

 

위 코드는 작동이 안되므로

binding.imageView.setVisibility(view.VISIBLE);

binding을 다른 곳에도 다 썼었다면 여기도 똑같이 적어줘야 한다.