Execute a method after an activity is visible to user

前端 未结 5 960
无人及你
无人及你 2021-01-31 18:04

I have an activity contains too many UI controls. I want to execute a method after make the activity visible.

An example i tried:

publi         


        
5条回答
  •  面向向阳花
    2021-01-31 18:59

    Move the code on to onAttachedToWindow()

    @Override
    public void onAttachedToWindow() {
       super.onAttachedToWindow();
       Toast.makeText(this, "Hi UI is fully loaded", Toast.LENGTH_SHORT).show();
    }
    

提交回复
热议问题