, 내가 원하는 것은이 google tutorial트랜잭션
에서 이루어집니다하지만 조각이 전환 이전에 생성이 것과 유사하다. 내가 그렇게하면 전환이 제대로 작동합니다. 하지만 난 단지로, 전체 화면에 표시 한 조각을 가지고 노력하고 버튼 (그려진 버튼을 사용하고 7 + API를 목표로이 방법
=====
을 사용할 수 없습니다 onTouch 이벤트) 그런 다음 두 번째 프래그먼트 및 그 반대로 대체합니다.
하지만 첫 번째 조각을 두 번째 조각으로 바꿀 때 빈 화면이 나타나거나 fragmentTransaction.show 및 fragmentTransaction.hide를 사용하면 빈 화면이 나타납니다. 빈 화면이 나오기 전에 두 번 전환 할 수 있습니다. 난 백 스택에 갖고 싶지 않아.
DiceTable diceTable = new DiceTable();
Logger logger = new Logger();
fragmentTransaction.add(diceTable, DICETABLE_TAG);
fragmentTransaction.add(logger, LOGGER_TAG);
fragmentTransaction.add(R.id.fragment_container, logger);
fragmentTransaction.add(R.id.fragment_container, diceTable);
그리고 하나의 방법에 (조각에서 호출) I 스위치를 수행합니다 :
나는 MainActivity의에서 onCreate에서 조각을 만드는 오전
Logger logger = (Logger)fragmentManager.findFragmentByTag(LOGGER_TAG);
DiceTable diceTable = (DiceTable)fragmentManager.findFragmentByTag(DICETABLE_TAG);
if (diceTable.isVisible()) {
fragmentTransaction.replace(R.id.fragment_container, logger);
fragmentTransaction.commit();
fragmentTransaction.hide(diceTable);
fragmentTransaction.show(logger);
}
else if (logger.isVisible()) {
fragmentTransaction.replace(R.id.fragment_container, diceTable);
fragmentTransaction.commit();
fragmentTransaction.hide(logger);
fragmentTransaction.show(diceTable);
}
이 내가이 작업을 수행하는 방법 아니다 ?
빈 화면 단편
교체