The type ActionBar.Tab is deprecated

I am trying to create scroll shortcuts in eclipse. But when I import android.app.ActionBar.Tab; he warns me as import . The type ActionBar.Tab is deprecated.

And he does most of my code as warnings, and he hits him.

import android.support.v4.app.FragmentActivity; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.ActionBar.TabListener; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.FragmentTabHost; import android.util.Log; public class MainActivity extends FragmentActivity implements TabListener { ActionBar actionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.Tab shops = actionBar.newTab(); shops.setText("SHOPS"); shops.setTabListener(this); ActionBar.Tab floorplan = actionBar.newTab(); floorplan.setText("FLOOR PLAN"); floorplan.setTabListener(this); ActionBar.Tab browser = actionBar.newTab(); browser.setText("BROWSER"); browser.setTabListener(this); ActionBar.Tab nav = actionBar.newTab(); nav.setText("NAVIGATION"); nav.setTabListener(this); actionBar.addTab(shops); actionBar.addTab(floorplan); actionBar.addTab(browser); actionBar.addTab(nav); } 

What can i do now? Is there any possible solution to overcome these warnings?

+5
source share
3 answers

Google is deprecated on the action bar tabs in favor of PagerTabStrip and PagerTitleStrip , and they are part of the v4 support library and serve as an immediate replacement.

Google provides samples for them, as you can see in SlidingTabsBasic or SlidingTabsColors , as explained in this video .

+9
source

Yes, the action bar tab is deprecated in android l. An alternative to this toolbar is introduced in this version. You can link to this link.

+3
source

Well, they are out of date and they will not receive any additional support.

You have several options:

  • You cannot use tabs.
  • You can create them manually using a line layout and 4 text views.
  • You can use ViewPager + PagerTabStrip.
  • Or you can just turn off warnings in the settings (but remember that they are there for a good reason)
+1
source

Source: https://habr.com/ru/post/1213861/


All Articles