
“If you do not ask, you will never know. If you know, you just need to ask. ”
This class was deprecated in API level 13.
Use the new Fragment and FragmentManager APIs instead; these are also available on older platforms through the Android compatibility package.
Perhaps this is the only working solution. It works out of the box, no crutches (deprecated, after all, does not count). Personally, I just forgot about LocalActivityManager, although I started developing for android back in the days when there were more phones with 8 Api Level than the rest, but they were actively supplanted.<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/bottom_bar" android:layout_below="@+id/top"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content"></TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent"></FrameLayout> </LinearLayout> </TabHost> </FrameLayout> // TabActivity ( deprecated), // deprecated , ? public class MainActivity extends android.app.ActivityGroup { TabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(getLocalActivityManager()); TabHost.TabSpec tabSpec; tabSpec = mTabHost.newTabSpec("tag1"); tabSpec.setIndicator(" 1");//use getString //TabActivity AndroidManifest tabSpec.setContent(new Intent(this, TabActivity.class)); mTabHost.addTab(tabSpec); tabSpec = mTabHost.newTabSpec("tag2"); tabSpec.setIndicator(" 2");//use getString //TabActivity AndroidManifest tabSpec.setContent(new Intent(this, TabActivity.class)); mTabHost.addTab(tabSpec); } } Source: https://habr.com/ru/post/317760/
All Articles