Всем привет, из-за устаревшего метода, не хочет компилироватся приложение. На что нужно поменять?
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
public class HomeActivity extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private ActionBar actionBar;
private TabPagerAdapter tabPagerAdapter;
private String[] tabs = { "Missed Calls", "Dialled", "Received" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
viewPager = (ViewPager) findViewById(R.id.pager);
tabPagerAdapter = new TabPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(tabPagerAdapter);
actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
/**
* on swipe select the respective tab
* */
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) { }
@Override
public void onPageScrollStateChanged(int arg0) { }
});
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) { }
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {}
}
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: FATAL EXCEPTION: main
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.eellazy.myapplication48/com.example.eellazy.myapplication48.HomeActivity}: java.lang.NullPointerException
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:156)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:153)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5299)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: Caused by: java.lang.NullPointerException
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at com.example.eellazy.myapplication48.HomeActivity.onCreate(HomeActivity.java:25)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5122)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:156)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:153)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5299)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-05 09:52:47.778 31042-31042/com.example.eellazy.myapplication48 E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)