i'm trying to create a menu using fragments so I can reuse my fragment on all my activity's, the code seems to work fine and I don't get any errors but whenever I run the emulator and try to use the menu it crashes. Here's my code.
navigation_bar_fragment.xml
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:layout_gravity="center"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hem"
android:id="@+id/Home_Button"
android:onClick="homeOnClick"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sök"
android:id="@+id/search"
android:onClick="searchOnClick"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kamera"
android:id="@+id/camera"
/>
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recept"
android:id="@+id/recepies"
/>
</RadioGroup>
NavigationBarFragment.java Here I try to go to HomePage activity when I press on the home button.
public class NavigationBarFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//Define that this class will use the navigation_bar_fragment xml file for the layout
View view = inflater.inflate(R.layout.navigation_bar_fragment, container, false);
return view;
}
public void homeOnClick (View view){
Intent homePage = new Intent(NavigationBarFragment.this.getActivity(), HomePage.class);
NavigationBarFragment.this.startActivity(homePage);
any help is appreciated.
0 comments:
Post a Comment