How to set icon to title bar for each Activity in TabLayout

后端 未结 3 883
旧时难觅i
旧时难觅i 2021-01-03 03:01

In my tablayout example, i have created 3 tabs, as usually i set 3 activities for each tab. I can set image to title bar of activity, which adds the intent to each tab. Due

3条回答
  •  孤街浪徒
    2021-01-03 03:24

    --------------------------- One more Action for the same --------------------
    Step Declare instance of class:
    Parent Tab Activity:
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tab_layout_title);
    TabLayoutActivity.tabLayout = this;
    TextView titleText = (TextView) findViewById(R.id.myTitle);
    titleText.setText("Care");
    
    Child Activity
    @Override 
        protected void onResume() {
            super.onResume();
            TabLayoutActivity.tabLayout.titleText.setText("Title name");
    
        }
    

提交回复
热议问题