я работаю над игрой. В игре есть таблица очков. и каждая игра имеет семь уровней. Я хочу переместить текущий уровень таблицы очков на следующий уровень. из-за того, что таблица точек имеет макет по умолчанию, каждое создание фрагмента игры загружает таблицу точек с макетом по умолчанию.
//GameFragment
public class GameFragment extends BaseFragment {
private PointTable mPointTable;
public FrameLayout frameLayout2,frameLayout3,frameLayout4;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
container.removeAllViews();
ViewGroup view =(ViewGroup)
inflater.inflate(R.layout.game_fragment,container,false);
view.setClipChildren(false);
mPointTable=PointTable.fromXml(getActivity().getApplicationContext(),view);
frameLayout3=view.findViewById(R.id.point_container);
frameLayout3.addView(mPointTable);
return view;
}
//
//Point Table Layout
<?xml version="1.0" encoding="utf-8"?>
<com.test.PointTable
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:point="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dced1e79"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.test.PointTable
android:id="@+id/point_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dced1e79"
point:above_point_color="@android:color/white"
point:blow_point_color="@android:color/white"
/>
</FrameLayout>
</com.test.PointTable>
//
//Nextsection event
@Override
public void onEvent(NextSectionEvent event){
PopupManager.closePopup();
int difficulty=mPlayingGame.boardConfiguration.diffuculty;
int remainPoint=mPlayingGame.gameState.remainedMoney;
if (remainPoint>0 && difficulty<8) {
difficulty++;
Common.eventBus.notify(new StartEvent(difficulty, remainPoint));
mBtnFirst = true;
}
//
//StartEvent event
@Override
public void onEvent(StartEvent event)
{
mPlayingGame=new Game();
mPlayingGame.boardConfiguration= new BoardConfiguration(event.difficulty);
remainPoint=event.remainPoint;
arrangeBoard(remainPoint);
mScreenController.openScreen(new GameFragment());
}
начать игру
![enter image description here](https://i.stack.imgur.com/GN0Vx.png)
конец первого раздела
![enter image description here](https://i.stack.imgur.com/oQyyB.png)
вторая секция
![enter image description here](https://i.stack.imgur.com/UdQQ2.png)
каждый следующий раздел событий сбрасывает таблицу очков, хотя я передаю каждый параметр игры событию nextsection. фактически он принимает параметр, но первое представление фрагмента идет с макетом таблицы точек по умолчанию.
спасибо за помощь, включая методологические изменения.