Currently working on an app, which has a MainActivity with a Fragment that contains multiple buttons. I cannot start another activity when clicking on the buttons.
I keep getting an error here saying
java.lang.IllegalArgumentException: No view found for id 0x7f090057 for fragment

I have two classes; a NavigationDrawer class (my MainActivity):
Java --- http://ift.tt/1AnGFeM | XML --- http://ift.tt/1AnGFeO
And a class named StartingFragment (which I want to be the main view when the drawer is closed/not active).
Java --- http://ift.tt/1AnGFeQ XML ---http://ift.tt/142LbTp
Here is the code that the error seems to refer to (from NavDrawer.java):
/** Swaps fragments in the main content view */
/** Starts an Activity when item is clicked */
private void selectItem(int position) {
// Create a new fragment and specify the tea type
// to show based on position
Fragment fragment = new StartingFragment();
Bundle args = new Bundle();
args.putInt(StartingFragment.TEA_TYPE_POS, position);
fragment.setArguments(args);
// Insert the fragment by replacing any existing fragment
FragmentManager fragManager = getFragmentManager();
fragManager.beginTransaction().replace(R.id.fragment_replace, fragment)
.commit();
// Highlight the selected item, update the title, and close the drawer
mDrawerList.setItemChecked(position, true);
setTitle(navDrawerTitles[position]);
navDrawerLayout.closeDrawer(mDrawerList);
}
I looked at this question here: http://ift.tt/1AnGFeS and I see that R.id.fragment_replace should be a child of the R.layout.nav_drawer, which is the case here. I also posted a very similar question a few days ago, although previously the app would just crash from the start; now it crashes on Button/AlertDialog clicks
However, I don't know what to adjust in my code. I get this error whenever I try to click on a button (and then click on the neutral/positive button of the AlertDialog that follows) from StartingFragment.java & starting_fragment.xml
No comments:
Post a Comment