When toolbar back button is pressed

后端 未结 4 1533
梦谈多话
梦谈多话 2021-01-28 00:01

how can I create a condition on my android app where When I pressed the back button on the toolbar some code will happening.

I tried this but it doesnt work.

<         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 00:36

    Toolbar toolbar;
    toolbar.setNavigationIcon(R.drawable.left_arrow_thick);
    setSupportActionBar(mToolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener()
    {
         @Override
         public void onClick(View v) 
         {
                    //write your code here
                    stopTimerTask();
         }
    });
    

提交回复
热议问题