I am creating an app which when pressing a button causes it to go to a new activity/window. However I keep getting an unexpected error every time I try this.
The following is part of the error from logcat:
06-21 10:42:13.232 22991-22991/edu.cmu.sphinx.pocketsphinx E/AndroidRuntime: FATAL EXCEPTION: main
Process: edu.cmu.sphinx.pocketsphinx, PID: 22991
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:4458)
at android.view.View.performClick(View.java:5204)
at edu.cmu.pocketsphinx.demo.Gvoice$2.run(Gvoice.java:108)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
The following is part of the java code which works except the W4 window which keep giving the error:
public void onButtonClick(View v) {
if (v.getId() == R.id.BHome) {
String str = a1.getText().toString();
//Go to the relevant page if any part of the phrase or word entered in the 'EditText' field contains 'xxx' which is not case sensitive
if (str.toLowerCase().contains("home")) {
Intent userintent = new Intent(Gvoice.this, PocketSphinxActivity.class);
startActivity(userintent);
} else if (str.toLowerCase().contains("W1")) {
Intent userintent = new Intent(Gvoice.this, W1.class);
startActivity(userintent);
} else if (str.toLowerCase().contains("W2")) {
Intent userintent = new Intent(Gvoice.this, W2.class);
startActivity(userintent);
} else if (str.toLowerCase().contains("W3")) {
Intent userintent = new Intent(Gvoice.this, W3.class);
startActivity(userintent);
} else if (str.toLowerCase().contains("W4")) {
Intent userintent = new Intent(Gvoice.this, W4.class);
startActivity(userintent);
} else {
Toast.makeText(getApplicationContext(), "Incorrect Information", Toast.LENGTH_SHORT).show();
}
}
}
If anyone knows where I should look that will be greatly appreciated
Aucun commentaire:
Enregistrer un commentaire