Setting onClickListeners for buttons in scenes programmatically

前端 未结 2 1834
盖世英雄少女心
盖世英雄少女心 2021-01-19 09:23

I have 2 layouts which contain the same buttons

layout_1.xml

  

        
2条回答
  •  深忆病人
    2021-01-19 09:34

    It would actually appear that a proper way to do this would be to on the second scene you define an action to be performed as such:

    mSecondScene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                     ((Button) mSecondScene.getSceneRoot().findViewById(R.id. button_1)).setOnClickListener( ... );
        }
    

    This will allow you to set your ClickListener on the View without the data binding to a generic click listener method. Then you can perform the Transition to the second scene and viola.

提交回复
热议问题