android - ActionBar.TabListener is deprecated what should use instead -
i trying use viewpager
actionbartabs
. referred examples , followed them. tablistener
, actionbar.tab
used in below code deprecated , not know should use alternative?
please provide example new api
my code:
public class mainactivity extends fragmentactivity implements actionbar.tablistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public void ontabselected(actionbar.tab tab, fragmenttransaction ft) { } @override public void ontabunselected(actionbar.tab tab, fragmenttransaction ft) { } @override public void ontabreselected(actionbar.tab tab, fragmenttransaction ft) { }
gradle:
apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "com.example.com.vpager_00" minsdkversion 23 targetsdkversion 23 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { ccompile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:design:22.2.0' }
compile dependency
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:design:22.2.0'
include in layout
<relativelayout android:id="@+id/main_layout" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:background="?attr/colorprimary" android:elevation="6dp" android:minheight="?attr/actionbarsize" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:popuptheme="@style/themeoverlay.appcompat.light"/> <android.support.design.widget.tablayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/toolbar" android:background="?attr/colorprimary" android:elevation="6dp" android:minheight="?attr/actionbarsize" android:theme="@style/themeoverlay.appcompat.dark.actionbar"/> <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_below="@id/tab_layout"/> </relativelayout>
Comments
Post a Comment