[Solved] Error:(106, 20) error: method onCreate(Bundle) is already defined in class MainActivity

The part I’m trying to add You should be adding this part into the existing onCreate method, not the entire method body // Load an ad into the AdMob banner view. AdView adView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .setRequestAgent(“android_studio:ad_template”).build(); adView.loadAd(adRequest); // Toasts the test ad message on the screen. Remove this after … Read more

[Solved] error: cannot find symbol method setContentView(int) [duplicate]

In fragment you inflate the layout not setContentView the code maybe look like this @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment1_layout, container, false); // Put your fragment code here return rootView; } 9 solved error: cannot find symbol method setContentView(int) [duplicate]

[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

Introduction When writing code in an object-oriented language, it is important to understand the concept of access modifiers. Access modifiers are used to control the visibility of class members, such as methods, variables, and constructors. One of the access modifiers is the protected modifier, which allows a class to access its own members, but not … Read more

[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

You are creating local variables of button1, button2 etc inside the onCreate method. This way, the generateQuestion method is unaware of these variables and uses the class variables with the same name (not included in your code, but I imagine you have somewhere declared them probably on top of your activity class) which are not … Read more