I wanted navigation drawer in all my activities.So i used a BaseActivity for Navigation drawer and extended other activities from base activity.Base activity has Navigation drawers. Dashboard activity is extending base activity but it raises exception when i try to use butterknife to bind views saying
java.lang.IllegalStateException: Required view 'dashboard_frameLayout' with ID 2131558517 for field 'frameLayout' was not found.
here are the relevant files
BaseActivity.java
public class BaseActivity extends AppCompatActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
ButterKnife.bind(this);
//set toolbar and both Navigation Drawer
}
DashboardActivity.java
public class DashBoardActivity extends BaseActivity {
@BindView(R.id.dashboard_frameLayout)
FrameLayout frameLayout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = getLayoutInflater().inflate(R.layout.activity_dashboard,frameLayout);
ButterKnife.bind(this,view);
init();
}
private void init() {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.dashboard_frameLayout);
if(fragment != null){
Utils.getInstance().addFragment(this,new Fragment_Dashboard(),R.id.dashboard_frameLayout);
}
}
}
activity_dashboard.xml
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard_frameLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
why the framelayout was not found in dashboard activity?