
안녕하세요. 첨부이미지와 같은 화면을 구성중입니다.
중간에 보이는 네모 버튼이 동적으로 바뀌는 구조인데, 스크롤 했을 때 버튼을 바꾸는 건 가능한데
버튼 클릭 -> 새 액티비티 실행 -> 새 액티비티 종료 -> 뷰페이저로 돌아옴
이 과정에서 어떻게 프래그먼트내 버튼을 새로 고침해야되는지 잘 모르겠습니다. 해당 버튼을 갱신하는 함수는 해당 프래그먼트의 메소드로 구현되어 있습니다.
public void setButtonText() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd");
String values[] = {dataFormat.format(calendar.getTime())};
Cursor cursor = db.rawQuery("select * from word_group where next_test_date = ?",values);
String textOfButton;
if (cursor.getCount() != 0)
{
cursor.moveToNext();
dataFormat = new SimpleDateFormat("yy년 MM월 dd일");
String testDate = dataFormat.format(calendar.getTime());
textOfButton = testDate + " 시험\n" + "클릭해서 시험 시작";
testWordButton.setText(textOfButton);
}
else
{
textOfButton = "오늘 볼 시험이 없습니다";
testWordButton.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
testWordButton.setText(textOfButton);
}
}