android - Bottom navigation view how to add bottombar to all layouts? -
i need bottom bar in every layouts, did code, error comes in setcontentview
in bottom bar java file.
import android.content.intent; import android.support.annotation.layoutres; import android.support.annotation.nonnull; import android.support.design.widget.bottomnavigationview; import android.support.v7.app.appcompatactivity; import android.support.v7.app.appcompatactivity; import android.view.menuitem; import android.widget.framelayout; public class bottom_bar extends appcompatactivity implements bottomnavigationview.onnavigationitemselectedlistener { bottomnavigationview btview; @override public void setcontentview(@layoutres int layoutresid) { super.setcontentview(layoutresid); coordinatorlayout colayout = (coordinatorlayout)getlayoutinflater().inflate(r.layout.bottombar,null); framelayout layout = (framelayout) colayout.findviewbyid(r.id.frame); getlayoutinflater().inflate(layoutresid,layout,true); super.setcontentview(colayout); btview = (bottomnavigationview) findviewbyid(r.id.bottombar); } @override public boolean onnavigationitemselected(@nonnull menuitem item) { switch (item.getitemid()) case r.id.profile: break; case r.id.homemain: intent = new intent(this,home.class); startactivity(i); break; } return false; } }
this bottombar.xml file. error like:
at com.example.android_heptshive.sam_school.bottom_bar.setcontentview(bottom_bar.java:24) @ com.example.android_heptshive.sam_school.home.oncreate(home.java:20) <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/codination" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.design.widget.bottomnavigationview android:id="@+id/bottombar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" app:menu="@menu/bottom_menu" android:background="@color/back" app:itemicontint="#ffffff"> </android.support.design.widget.bottomnavigationview> <framelayout android:id="@+id/frame" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginbottom="55dp"/> </android.support.design.widget.coordinatorlayout>
Comments
Post a Comment