Skip to content
Advertisement

when I click on the button the app crashes

Here the error:

JavaScript

java code:

JavaScript

xml file:

JavaScript

when I click on the button the app crashes

Using tabbed activity from android studio example whit legacy android studio libraries

Any help is welcome

Advertisement

Answer

You can not use android:onClick attribute in fragment layout unless you create it in the activity class, not the fragment class.

In your case:

Here the error: java.lang.IllegalStateException: Could not find method OpenRadio(View) in a parent or ancestor Context for android:onClick attribute defined on view class

The system looks at the activity class that hosts Fragment1, and didn’t find OpenRadio(View) method.

So, you need to either move the OpenRadio(View) method to the activity class in case the code it holds is not relevant to the fragment; or you need to build some communication between the fragment and the activity when OpenRadio(View) of the activity is called, for this part you can check answers here.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement