-3

The purpose of this app is the take a editText that would be an acronym and show what it means. (e.g. lol is laugh out loud) the problem is no matter what i input it always returns the else statement of "none found" program compiles fine. Thanks for your help!!

// Define Variables
EditText et1;
TextView tv1;
Button button;
String acronym;
String lol,omg;

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

    et1=(EditText) findViewById(R.id.editText);
    tv1=(TextView) findViewById(R.id.textView);
    button=(Button) findViewById(R.id.button);
    acronym=et1.getText().toString().toLowerCase();


    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

        if (acronym.equals(lol)) {
            tv1.setText("lol means laugh out loud");
        } else if(acronym.equals(omg)) {
            tv1.setText("omg means oh my god");
        } else {
            tv1.setText("none found.");
        }
        }
    });
}
2002ws6
  • 1
  • 1

1 Answers1

-4
 Just put this line in to onclick events 

    acronym=et1.getText().toString().toLowerCase();

    like : 

    button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            acronym=et1.getText().toString().toLowerCase();
           if (acronym.equals("lol")) {
        tv1.setText("lol means laugh out loud");
    } else if(acronym.equals("omg")) {
        tv1.setText("omg means oh my god");
    } else {
        tv1.setText("none found.");
    }
            }
        });
Digvesh Patel
  • 6,503
  • 1
  • 20
  • 34