Android _ 서버연동_채팅/Android - UI

리사이클러뷰 갱신, 새로고침, 액티비티새로고침

글자줍기 2021. 11. 25. 11:10
반응형

https://todaycode.tistory.com/55

 

recyclerView를 업데이트 하는 5가지 방법 (notifyDataSetChanged를 사용하지 말자)

1. 사건 배경 2. 증상 3. 리스트를 업데이트하는 5가지 방법  3-1. 전체 업데이트  3-1-1. notifyDataSetChanged  3-2. 변경  3-2-1. notifyItemChanged  3-2-2. notifyItemRangeChanged  3-3. 추가  3-3..

todaycode.tistory.com

- 리사이클러뷰 체인지드 노티

- 스크롤뷰, 스크롤뷰 다시 그려주기

 

 

A액티비티 B액티비티가 있을때

A액티비티에서 B액티비티 새로고침 시키기 

1.새로고침하고자 하는 Activity의 Context를 전역변수로 만들어 준다.
     public static Context CONTEXT;

2.onCreate 부분에서 Context의 값을 지정해준다.
     CONTEXT = this;

3.다른 Activity에서 위의 Context의 onResume() 메서드를 호출한다
     ((ListActivity)ListActivity.CONTEXT).onResume();

※ 해당 내용은 onResume() 메서드를 통해 새로고침한다는 가정하에 작성한 내용.
onResume() 메서드에 새로고침에 관한 내용이 있어야 한다.
@Override
public void onResume() {
   super.onResume();
   
   ListView.notifyDataSetChanged();
   
}


출처: https://debugdaldal.tistory.com/119 [달달한 디버깅]

반응형