getSupportActionBar with YouTubeBaseActivity

前端 未结 2 391
闹比i
闹比i 2020-12-05 20:30

I am trying out youtube video to be played on my app. I understand this can be achieve by extending activity as YouTubeBaseActivity by doing this I don\'t have access to you

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 21:14

    I was not interested in moving my already completed code to fragment for just adding a toolbar with a back button. So I figured out an easy way to do it.

    Inside the layout xml I added a TextView which looks like a toolbar. Here's the code for the Textview. Also, you need to add a vector asset (back icon) in the drawable folder

    
    

    And Simply adding onclicklistener on the textview for back press

    val actionbarTitle = findViewById(R.id.actionbartitle)
     actionbarTitle.setOnClickListener {
               super.onBackPressed()
            }
    

    Here's how the final result look likes! Have your cup of coffee :)

提交回复
热议问题