안녕하세요. 예제참조해서 프래그먼트 페이지를 만들었는데..
main[상위]에서 값을 변경했을 경우 그 값에 맞게 하위 프래그먼트페이지들을 갱신시키고 싶습니다.
현재 mainActivity 아래에 fragment1/fragment2/fragment3
세개의 프래그먼트 페이지가 있습니다.
상단레이아웃에 세개의 1,2,3버튼을 만들어서 하단의 fragment에 각각의 페이지를 출력합니다.

위에서 마지막버튼인 별표벼튼을 눌렀을 때 SharedPreferences로 특정 값을 저장하고,
프래그먼트1,2,3페이지에 각각 변경된 값을 출력합니다.
현재는 갱신이 안되어서, 상단의 1/2/3 각 버튼을 눌러야 그제서야 갱신된 값이 출력되고요..
제가 원하는 기능은, 별표값을 눌렀을 때 바로 프래그먼트 페이지가 갱신되는 것입니다.
가령 현재 프래그먼트2 페이지인 경우, 2페이지를 갱신시키고,
1페이지면 1페이지를 갱신시켜주고싶은데.. 현재 띄워진 프래그먼트를 식별해서 갱신하는 것이
가능한가요?
현재 프래그먼트를 이동할 때 아래와 같이 구현했습니다.(frag2,3은 생략합니다)
int mCurrentFragmentIndex;
public final static int frag1 = 0;
public final static int frag2= 1;
public final static int frag3 = 2;
//버튼 누르는 부분,가령 1페이지를 선택했을 때
mCurrentFragmentIndex = frag1;
fragmentReplace(mCurrentFragmentIndex);
//
private void fragmentReplace(int reqNewFragmentIndex) {
Fragment newFragment = null;
Log.e(TAG, "fragmentReplace " + reqNewFragmentIndex);
newFragment = getFragment(reqNewFragmentIndex);
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment, newFragment);
transaction.commit();
}
private Fragment getFragment(int index)
{
Fragment newFragment = null;
switch (index) {
case frag1:
newFragment = new frag1();//frag1클래스
break;
}
방법을 찾아보니 프래그먼트 태그를 사용하면 된다는데, 구체적으로 이 태그 string 이
무엇을 의미하고 어떻게 그 값을 지정하는 것인가요?