Android : Android Unfortunately app has stopped? [duplicate]

on Monday, October 6, 2014



I have to make an app where the user inputs and then the AI responds but when I input some text and press send it gives me the message "Unfortunately, app has stopped".


Here is my code:


Here is the code for sending:



<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Button"
android:id="@+id/Send_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:onClick="Zdenka" />...


Here is the start of the .java file:



EditText Text, OdgBox;
String odg;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);

EditText Text = (EditText) findViewById(R.id.Txt); //User input
Button Btn = (Button) findViewById(R.id.Send_btn); //Send button
TextView Output = (TextView) findViewById(R.id.TextView); //AI output

}...


And the last part of the java file:



...
public void Zdenka (TextView Output, EditText Text, String odg) {

String Text1 = Text.toString().toLowerCase();


if (Text1 == "živjo") {

odg = "Živjo";

}
else if (Text1 == "zivjo") {
odg = "oj";
}
else{ odg = "Ne razumem."; }



Output.setText(odg);


Thanks for the help!


0 comments:

Post a Comment