Fragment
にfindViewById
を使用するとエラーが発生します。findViewByIdを使用しようとしたときにフラグメントにエラーが発生しました
どうすれば解決できますか?
public class Discover extends Fragment {
private static final String TAG = "Discover";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_discover, container, false);
Log.d(TAG, "onCreate: starting.");
setupBottomNavigationView();
return root;
}
private void setupBottomNavigationView(){
Log.d(TAG, "setupBottomNavigationView: setting up BottomNavigationView");
BottomNavigationViewEx bottomNavigationViewEx = (BottomNavigationViewEx) findViewById(R.id.bottomNavViewBar);
BottomNavigationViewHelper.setupBottomNavigationView(bottomNavigationViewEx);
}
public void onResume(){
super.onResume();
// Set title bar
((LandingPage) getActivity())
.setActionBarTitle("Discover Photos");
}
}
}
をそれがエラーをもたらす(それがブラケットを強調)on setupBottomNavigationView(); –
これをあなたのsetupBottomNavigationView(root)に追加するだけです。 –
ありがとう、これは –