public class Fragment_Statistik extends Fragment implements View.OnClickListener {
TextView currentBerrys,currentFish,currentTrees,currentLumber,currentStones,currentStonebricks;
ProgressBar progressBarBerrys, progressBarFish, progressBarTrees,progressBarLumber,progressBarStones,progressBarStonebricks;
FloatingActionButton fab;
Button upgrade;
boolean running = true;
Dialog popupUpgradeWarehouse;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_statistik, container, false);
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
fab = getView().findViewById(R.id.floatingActionButton);
currentBerrys = getView().findViewById(R.id.textView_current_berrys);
currentFish = getView().findViewById(R.id.textView_current_fish);
currentTrees = getView().findViewById(R.id.textView_current_trees);
currentLumber = getView().findViewById(R.id.textView_current_lumber);
currentStones = getView().findViewById(R.id.textView_current_stone);
currentStonebricks = getView().findViewById(R.id.textView_current_stonebricks);
progressBarBerrys = getView().findViewById(R.id.progressBarBerrys);
progressBarFish = getView().findViewById(R.id.progressBarFish);
progressBarTrees = getView().findViewById(R.id.progressBarTree);
progressBarLumber = getView().findViewById(R.id.progressBarLumber);
progressBarStones = getView().findViewById(R.id.progressBarStone);
progressBarStonebricks = getView().findViewById(R.id.progressBarStonebrick);
fab.setOnClickListener(this);
popupUpgradeWarehouse = new Dialog(getContext());}
showPopupupgradeWarehouse运行正常。删除所有其他代码后,会显示对话框。
public void showPopupUpgradeWarehouse() {
popupUpgradeWarehouse.setContentView(R.layout.popup_upgrade_warehouse);
upgrade = getView().findViewById(R.id.popupButtonUpgrade);
ImageView popupImageViewClose;
popupImageViewClose = getView().findViewById(R.id.popupImageViewClose);
upgrade.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
popupUpgradeWarehouse.show();
}