I'm extremely new to Android and Java but this site has helped me until now, so thanks to you all!
I am building an app that has two tabs, in one tab I have created some buttons and in the corresponding activity I have an OnClickListener. When I run the app it forces close and I get the error:
ERROR/AndroidRuntime(25971): java.lang.IllegalStateException: Could not find a method myClickHandler(View) in the activity class com.test.rate.MainActivity for onClick handler on view class android.widget.Button with id 'CalculateButton'
It's probably really simple but help!
Okay yeah I should have added some code:
The Activity:
public class MetricActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.metriclayout);
final Button button = (Button) findViewById(R.id.CalculateButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
And the button in the tab layout:
<Button android:layout_height="wrap_content" android:text="Calculate" android:layout_width="wrap_content" android:id="@+id/CalculateButton" android:onClick="myClickHandler" android:layout_gravity="center"></Button>