I've created a button which will open a new activity, but when I start the app and click on the button, the application just immediately restarts without any logcat errors. Here is my code:
public class amumu extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.amumu, container, false);
}
public void OnClickAmumuRunes(View view){
Intent GoToRunes = new Intent(view.getContext(), amumurunes.class);
startActivity(GoToRunes);
}
public void OnClickAmumuBuild(View view){
Intent GoToRunes = new Intent(view.getContext(), amumubuild.class);
startActivity(GoToRunes);
}
This is the code which I want to open, but I can't:
public class amumubuild extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.amumubuild, container, false);
}
}
and this is a fragmentclass where is tablayout in which first class is
public class FragmentClass extends AppCompatActivity {
private ViewPager viewPager;
private TabLayout tabLayout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragments);
initViews();
setuppager();
}
private void initViews(){
viewPager = findViewById(R.id.ViewPager);
tabLayout = findViewById(R.id.tab);
}
private void setuppager(){
PagerAdapter pagerAdapter = new SlideAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager);
}
public void OnClickDisplayToastAmumu(View view) {
Toast.makeText(this,"Amumu",Toast.LENGTH_SHORT).show();
}
public void OnClickDisplayToastLee(View view) {
Toast.makeText(this,"Lee Sin",Toast.LENGTH_SHORT).show();
}
public void OnClickDisplayToastPantheon(View view) {
Toast.makeText(this,"Pantheon",Toast.LENGTH_SHORT).show();
}
public void OnClickDisplayToastNami(View view) {
Toast.makeText(this,"Nami",Toast.LENGTH_SHORT).show();
}