연락처 App을 만들고 있습니다.
ContentProvider DB를 활용해 Fragment에 RecyclerView에 미리 입력한 데이터 30개를 뿌렸습니다.( 이것이 초기화면)
NavigationView를 이용해 1. 서울 2. 경기 3. 대구 등등 ... 만약 서울을 눌렀을 때 RecyclerView에서 서울 사는 사람만 표시하도록 하고 싶습니다.
RecyclerView는 Fragment에 있고, CursorAdapter를 이용했고, MainActivity에 NavigationView를 달고 리스너를 사용중입니다.
현재 상태로썬 Navigationview에서 서울을 누르면 Log로는 서울 사는 인원만 리스트가 뜨는데 어떻게 뷰를 바꿔야 할지 ...
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
//Lab_1
if (id == R.id.lab_1) {
SQLiteDatabase db = mDbHelper.getWritableDatabase();
Cursor result = db.rawQuery("select * from Contract where depart = " + "'Lab 1'" + ";", null);
result.moveToFirst();
while (!result.isAfterLast()) {
Log.d("TAG", "lab_1");
String name = result.getString(1);
String naesun = result.getString(2);
String number = result.getString(3);
String email = result.getString(4);
String depart = result.getString(5);
//필요한 작업 처리
result.moveToNext();
Log.d("TAG", ""+name +" / " + naesun + " / " + number + " / " + email + " / " + depart);
}
result.close();
예를 들자면 지금 이런식으로 Activity에 있는데 어떻게 화면을 갱신할까요 ?